From 8c005503e8e1a6544ea8e3095c34a228573b129d Mon Sep 17 00:00:00 2001 From: Bene Date: Thu, 25 Sep 2014 17:45:51 +0200 Subject: [PATCH] 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 --- includes/specialpage/SpecialPageFactory.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 -- 2.20.1