From: Bene Date: Thu, 25 Sep 2014 15:45:51 +0000 (+0200) Subject: Fix string callbacks for special page registration X-Git-Tag: 1.31.0-rc.0~13823^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/bilan.php?a=commitdiff_plain;h=8c005503e8e1a6544ea8e3095c34a228573b129d;p=lhc%2Fweb%2Fwiklou.git Fix string callbacks for special page registration 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 --- diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index 7904140e2f..679492ae06 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -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