Fix string callbacks for special page registration
authorBene <benestar.wikimedia@gmail.com>
Thu, 25 Sep 2014 15:45:51 +0000 (17:45 +0200)
committerBene <benestar.wikimedia@gmail.com>
Thu, 25 Sep 2014 15:49:04 +0000 (17:49 +0200)
Currently registering a special page with a factory by passing the
callback string does not work because the is_string check comes
before the is_callback check. If we change the order of this if-
clauses we can also support callbacks like 'Factory::createPage'.

Change-Id: I751f97026ed8c580732c74d66b2804dd180ed16f

includes/specialpage/SpecialPageFactory.php

index 7904140..679492a 100644 (file)
@@ -402,12 +402,12 @@ class SpecialPageFactory {
                if ( isset( $specialPageList[$realName] ) ) {
                        $rec = $specialPageList[$realName];
 
-                       if ( is_string( $rec ) ) {
-                               $className = $rec;
-                               $page = new $className;
-                       } elseif ( is_callable( $rec ) ) {
+                       if ( is_callable( $rec ) ) {
                                // Use callback to instantiate the special page
                                $page = call_user_func( $rec );
+                       } elseif ( is_string( $rec ) ) {
+                               $className = $rec;
+                               $page = new $className;
                        } elseif ( is_array( $rec ) ) {
                                $className = array_shift( $rec );
                                // @deprecated, officially since 1.18, unofficially since forever