Merge "Rewrite ORMTable::unprefixFieldNames"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 21 Oct 2014 09:45:31 +0000 (09:45 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 21 Oct 2014 09:45:31 +0000 (09:45 +0000)
1  2 
includes/db/ORMTable.php

diff --combined includes/db/ORMTable.php
@@@ -129,7 -129,6 +129,7 @@@ class ORMTable extends DBAccessBase imp
         * Gets the db field prefix.
         *
         * @since 1.20
 +       * @deprecated since 1.25, use the $this->fieldPrefix property instead
         *
         * @return string
         */
         * @return string
         */
        public function getPrefixedField( $field ) {
 -              return $this->getFieldPrefix() . $field;
 +              return $this->fieldPrefix . $field;
        }
  
        /**
         * @return array
         */
        public function unprefixFieldNames( array $fieldNames ) {
-               return array_map( array( $this, 'unprefixFieldName' ), $fieldNames );
+               $start = strlen( $this->fieldPrefix );
+               return array_map( function( $fieldName ) use ( $start ) {
+                       return substr( $fieldName, $start );
+               }, $fieldNames );
        }
  
        /**
         * @return string
         */
        public function unprefixFieldName( $fieldName ) {
 -              return substr( $fieldName, strlen( $this->getFieldPrefix() ) );
 +              return substr( $fieldName, strlen( $this->fieldPrefix ) );
        }
  
        /**