Legoktm has uploaded a new change for review. https://gerrit.wikimedia.org/r/171458
Change subject: Deprecate MWFunction::newObj() in favor of ObjectFactory ...................................................................... Deprecate MWFunction::newObj() in favor of ObjectFactory Change-Id: Iaa803311409cf7b649f64f69bafe2935a418d31c --- M includes/StubObject.php M includes/specialpage/SpecialPageFactory.php M includes/utils/MWFunction.php M tests/phpunit/includes/MWFunctionTest.php 4 files changed, 15 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/58/171458/1 diff --git a/includes/StubObject.php b/includes/StubObject.php index 8878660..639177a 100644 --- a/includes/StubObject.php +++ b/includes/StubObject.php @@ -110,7 +110,10 @@ * @return object */ public function _newObject() { - return MWFunction::newObj( $this->class, $this->params ); + return ObjectFactory::getObjectFromSpec( array( + 'class' => $this->class, + 'args' => $this->params, + ) ); } /** diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index b110bda..c2680e4 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -414,7 +414,10 @@ // @deprecated, officially since 1.18, unofficially since forever wfDeprecated( "Array syntax for \$wgSpecialPages is deprecated ($className), " . "define a subclass of SpecialPage instead.", '1.18' ); - $page = MWFunction::newObj( $className, $rec ); + $page = ObjectFactory::getObjectFromSpec( array( + 'class' => $className, + 'args' => $rec, + ) ); } elseif ( $rec instanceof SpecialPage ) { $page = $rec; //XXX: we should deep clone here } else { diff --git a/includes/utils/MWFunction.php b/includes/utils/MWFunction.php index 3a0492d..57fe79f 100644 --- a/includes/utils/MWFunction.php +++ b/includes/utils/MWFunction.php @@ -50,14 +50,14 @@ * @param string $class * @param array $args * @return object + * @deprecated 1.25 Use ObjectFactory::getObjectFromSpec() instead */ public static function newObj( $class, $args = array() ) { - if ( !count( $args ) ) { - return new $class; - } + wfDeprecated( __METHOD__, '1.25' ); - $ref = new ReflectionClass( $class ); - - return $ref->newInstanceArgs( $args ); + return ObjectFactory::getObjectFromSpec( array( + 'class' => $class, + 'args' => $args, + ) ); } } diff --git a/tests/phpunit/includes/MWFunctionTest.php b/tests/phpunit/includes/MWFunctionTest.php index f2a720e..f4d1799 100644 --- a/tests/phpunit/includes/MWFunctionTest.php +++ b/tests/phpunit/includes/MWFunctionTest.php @@ -13,6 +13,7 @@ $args = array( $arg1, $arg2, $arg3, $arg4 ); $newObject = new MWBlankClass( $arg1, $arg2, $arg3, $arg4 ); + $this->hideDeprecated( 'MWFunction::newObj' ); $this->assertEquals( MWFunction::newObj( 'MWBlankClass', $args )->args, $newObject->args -- To view, visit https://gerrit.wikimedia.org/r/171458 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaa803311409cf7b649f64f69bafe2935a418d31c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits