From: Brad Jorsch Date: Fri, 10 Oct 2014 19:22:35 +0000 (-0400) Subject: API: Fix ApiQueryBacklinks redirlinks X-Git-Tag: 1.31.0-rc.0~13638^2 X-Git-Url: http://git.cyclocoop.org/%27-%20%20.%20url_absolue%28find_in_path%28%27spip_style.css%27%29%29%20%20%20.%20url_absolue%28find_in_path%28%27prive/spip_style.css%27%29%29%20.%20%27?a=commitdiff_plain;h=1204a50435cda092cd3ec00adfc3533a59bfa73a;p=lhc%2Fweb%2Fwiklou.git API: Fix ApiQueryBacklinks redirlinks The fast case needs to pass the redirlinks subarray through array_values and set an indexed tag name. Bug: 71907 Change-Id: I865aad6485a2598c9e574ab5c38e8e0923d11ddd --- diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 52445d279f..f00a6e7f33 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -287,7 +287,6 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $res = $this->select( __METHOD__ ); $count = 0; - $result = $this->getResult(); foreach ( $res as $row ) { $ns = $this->hasNS ? $row->{$this->bl_ns} : NS_FILE; @@ -319,10 +318,6 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $parentID = $this->pageMap[$ns][$row->{$this->bl_title}]; // Put all the results in an array first $this->resultArr[$parentID]['redirlinks'][$row->page_id] = $a; - $result->setIndexedTagName( - $this->resultArr[$parentID]['redirlinks'], - $this->bl_code - ); } else { $resultPageSet->processDbRow( $row ); } @@ -427,7 +422,15 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { if ( is_null( $resultPageSet ) ) { // Try to add the result data in one go and pray that it fits - $fit = $result->addValue( 'query', $this->getModuleName(), array_values( $this->resultArr ) ); + $code = $this->bl_code; + $data = array_map( function ( $arr ) use ( $result, $code ) { + if ( isset( $arr['redirlinks'] ) ) { + $arr['redirlinks'] = array_values( $arr['redirlinks'] ); + $result->setIndexedTagName( $arr['redirlinks'], $code ); + } + return $arr; + }, array_values( $this->resultArr ) ); + $fit = $result->addValue( 'query', $this->getModuleName(), $data ); if ( !$fit ) { // It didn't fit. Add elements one by one until the // result is full.