X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecialpage%2FSpecialPageFactory.php;h=40fcd74b15a84afc46ceaab078e17ddb2a9dc0ae;hp=8134c9a8296433edca848ae6fbe965804db0188f;hb=3224bdabc08f522da81478a63971c949cee40bc6;hpb=a389d94551f1ece9112c66bf8a53f66d3c15c0b2 diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index 8134c9a829..40fcd74b15 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -34,6 +34,7 @@ use RequestContext; use SpecialPage; use Title; use User; +use Wikimedia\ObjectFactory; /** * Factory for handling the special page list and generating SpecialPage objects. @@ -191,7 +192,12 @@ class SpecialPageFactory { 'ApiHelp' => \SpecialApiHelp::class, 'Blankpage' => \SpecialBlankpage::class, 'Diff' => \SpecialDiff::class, - 'EditTags' => \SpecialEditTags::class, + 'EditTags' => [ + 'class' => \SpecialEditTags::class, + 'services' => [ + 'PermissionManager', + ], + ], 'Emailuser' => \SpecialEmailUser::class, 'Movepage' => \MovePageForm::class, 'Mycontributions' => \SpecialMycontributions::class, @@ -221,6 +227,9 @@ class SpecialPageFactory { /** @var Language */ private $contLang; + /** @var ObjectFactory */ + private $objectFactory; + /** * TODO Make this a const when HHVM support is dropped (T192166) * @@ -241,11 +250,17 @@ class SpecialPageFactory { /** * @param ServiceOptions $options * @param Language $contLang + * @param ObjectFactory $objectFactory */ - public function __construct( ServiceOptions $options, Language $contLang ) { + public function __construct( + ServiceOptions $options, + Language $contLang, + ObjectFactory $objectFactory + ) { $options->assertRequiredOptions( self::$constructorOptions ); $this->options = $options; $this->contLang = $contLang; + $this->objectFactory = $objectFactory; } /** @@ -412,14 +427,22 @@ class SpecialPageFactory { if ( isset( $specialPageList[$realName] ) ) { $rec = $specialPageList[$realName]; - if ( is_callable( $rec ) ) { - // Use callback to instantiate the special page - $page = $rec(); - } elseif ( is_string( $rec ) ) { - $className = $rec; - $page = new $className; - } elseif ( $rec instanceof SpecialPage ) { + if ( $rec instanceof SpecialPage ) { + wfDeprecated( + "a SpecialPage instance (for $realName) in " . + '$wgSpecialPages or from the SpecialPage_initList hook', + '1.34' + ); + $page = $rec; // XXX: we should deep clone here + } elseif ( is_array( $rec ) || is_string( $rec ) || is_callable( $rec ) ) { + $page = $this->objectFactory->createObject( + $rec, + [ + 'allowClassName' => true, + 'allowCallable' => true + ] + ); } else { $page = null; }