Internal calls to this method show up in my XDebug profiling as
the second most called method (after array_key_exists). Called
10000 times. Sure, it's very cheap and clearly not a bottleneck.
But just not necesarry to have a method for that. The benefit of
having a method is to have a dynamic prefix that can change
depending on other things in an object. But I think this is not
a good idea for a prefix.
Since this is protected it is part of the contract of this class.
I already cleaned known subclasses. Should be @deprecated for
some time and can be removed later.
Change-Id: I46a0d7e072d0a69e9aef5f77e92044b62e3d0ce7
* 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 string
*/
public function unprefixFieldName( $fieldName ) {
- return substr( $fieldName, strlen( $this->getFieldPrefix() ) );
+ return substr( $fieldName, strlen( $this->fieldPrefix ) );
}
/**
class PageORMTableForTesting extends ORMTable {
+ public function __construct() {
+ $this->fieldPrefix = 'page_';
+ }
+
/**
* @see ORMTable::getName
*
'title' => 'str',
);
}
-
- /**
- * @see ORMTable::getFieldPrefix
- *
- * @return string
- */
- protected function getFieldPrefix() {
- return 'page_';
- }
}
class TestORMTable extends ORMTable {
+ public function __construct() {
+ $this->fieldPrefix = 'test_';
+ }
+
/**
* Returns the name of the database table objects of this type are stored in.
*
'time' => 'str', // TS_MW
);
}
-
- /**
- * Gets the db field prefix.
- *
- * @since 1.20
- *
- * @return string
- */
- protected function getFieldPrefix() {
- return 'test_';
- }
}