Deprecate internal ORMTable::unprefixFieldName(s)
authorThiemo Mättig <thiemo.maettig@wikimedia.de>
Tue, 14 Oct 2014 13:23:36 +0000 (15:23 +0200)
committerThiemo Mättig (WMDE) <thiemo.maettig@wikimedia.de>
Tue, 21 Oct 2014 12:00:56 +0000 (12:00 +0000)
unprefixFieldNames is not used anywhere outside of the class. Why
should it?

unprefixFieldName became unused in I19194f1, but I did not removed
it because it is public.

The fact that both methods are public is a mistake as far as I can
tell. I can't think of a good reason to do that.

Change-Id: Iafc527b5d534648a962a8c2015d21403362bb573

includes/db/IORMTable.php
includes/db/ORMTable.php

index 4dc693a..6e262e8 100644 (file)
@@ -442,10 +442,11 @@ interface IORMTable {
         * Takes an array of field names with prefix and returns the unprefixed equivalent.
         *
         * @since 1.20
+        * @deprecated since 1.25, will be removed
         *
-        * @param array $fieldNames
+        * @param string[] $fieldNames
         *
-        * @return array
+        * @return string[]
         */
        public function unprefixFieldNames( array $fieldNames );
 
@@ -453,6 +454,7 @@ interface IORMTable {
         * Takes a field name with prefix and returns the unprefixed equivalent.
         *
         * @since 1.20
+        * @deprecated since 1.25, will be removed
         *
         * @param string $fieldName
         *
index 31f32e5..1868073 100644 (file)
@@ -778,12 +778,26 @@ class ORMTable extends DBAccessBase implements IORMTable {
         * Takes an array of field names with prefix and returns the unprefixed equivalent.
         *
         * @since 1.20
+        * @deprecated since 1.25, will be removed
         *
-        * @param array $fieldNames
+        * @param string[] $fieldNames
         *
-        * @return array
+        * @return string[]
         */
        public function unprefixFieldNames( array $fieldNames ) {
+               wfDeprecated( __METHOD__, '1.25' );
+
+               return $this->stripFieldPrefix( $fieldNames );
+       }
+
+       /**
+        * Takes an array of field names with prefix and returns the unprefixed equivalent.
+        *
+        * @param string[] $fieldNames
+        *
+        * @return string[]
+        */
+       private function stripFieldPrefix( array $fieldNames ) {
                $start = strlen( $this->fieldPrefix );
 
                return array_map( function( $fieldName ) use ( $start ) {
@@ -795,12 +809,15 @@ class ORMTable extends DBAccessBase implements IORMTable {
         * Takes a field name with prefix and returns the unprefixed equivalent.
         *
         * @since 1.20
+        * @deprecated since 1.25, will be removed
         *
         * @param string $fieldName
         *
         * @return string
         */
        public function unprefixFieldName( $fieldName ) {
+               wfDeprecated( __METHOD__, '1.25' );
+
                return substr( $fieldName, strlen( $this->fieldPrefix ) );
        }
 
@@ -837,7 +854,7 @@ class ORMTable extends DBAccessBase implements IORMTable {
                $result = (array)$result;
 
                $rawFields = array_combine(
-                       $this->unprefixFieldNames( array_keys( $result ) ),
+                       $this->stripFieldPrefix( array_keys( $result ) ),
                        array_values( $result )
                );