From: Brad Jorsch Date: Mon, 22 Jul 2013 17:08:31 +0000 (-0400) Subject: Fix exception in ApiPageSet X-Git-Tag: 1.31.0-rc.0~19143^2 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=a860b9a5b56d79339ef95b7f3a332f2394702ed1;p=lhc%2Fweb%2Fwiklou.git Fix exception in ApiPageSet ApiPageSet is calling $this->profileOut(), then calling a function that calls $this->profileDBIn(). Move that function to after a new $this->profileIn(). Also, add a unit test for this situation. Bug: 51821 Change-Id: Ib4dbfb567faadcd5e3d7d058ca6bdf8b4c83f634 --- diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index 9fdad2ba38..b05cb2b67b 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -152,7 +152,6 @@ class ApiPageSet extends ApiBase { if ( !$isDryRun ) { $generator->executeGenerator( $this ); wfRunHooks( 'APIQueryGeneratorAfterExecute', array( &$generator, &$this ) ); - $this->resolvePendingRedirects(); } else { // Prevent warnings from being reported on these parameters $main = $this->getMain(); @@ -163,6 +162,10 @@ class ApiPageSet extends ApiBase { $generator->profileOut(); $this->profileIn(); + if ( !$isDryRun ) { + $this->resolvePendingRedirects(); + } + if ( !$isQuery ) { // If this pageset is not part of the query, we called profileIn() above $dbSource->profileOut(); diff --git a/tests/phpunit/includes/api/query/ApiQueryBasicTest.php b/tests/phpunit/includes/api/query/ApiQueryBasicTest.php index 403034b42e..1a2aa83247 100644 --- a/tests/phpunit/includes/api/query/ApiQueryBasicTest.php +++ b/tests/phpunit/includes/api/query/ApiQueryBasicTest.php @@ -320,6 +320,32 @@ class ApiQueryBasicTest extends ApiQueryTestBase { self::$categorymembers ) ); } + /** + * Test bug 51821 + */ + public function testGeneratorRedirects() { + $this->editPage( 'AQBT-Target', 'test' ); + $this->editPage( 'AQBT-Redir', '#REDIRECT [[AQBT-Target]]' ); + $this->check( array( + array( 'generator' => 'backlinks', 'gbltitle' => 'AQBT-Target', 'redirects' => '1' ), + array( + 'redirects' => array( + array( + 'from' => 'AQBT-Redir', + 'to' => 'AQBT-Target', + ) + ), + 'pages' => array( + '6' => array( + 'pageid' => 6, + 'ns' => 0, + 'title' => 'AQBT-Target', + ) + ), + ) + ) ); + } + /** * Recursively merges the expected values in the $item into the $all */