From 8d2b1a1b58c634459db7813553be034b9be51d65 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 17 Jun 2012 18:46:21 +0200 Subject: [PATCH] show old protection in prop=info, if no new protection exists prop=info shows only old protection from page.page_restrictions, if a new protection in table page_restrictions was found, because only in the foreach was the old protection checked, but that foreach operated on pages, which was found in table page_restrictions. Doing an extra foreach over the array of old protection fix this. This change also removes the join from the query to table page_restrictions, because the code already know the needed ns/dbkey. Change-Id: I52111f30e4fa9550c82d18db33efda5edec59c66 --- includes/api/ApiQueryInfo.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 87fd58b5a7..ba853cd390 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -429,15 +429,14 @@ class ApiQueryInfo extends ApiQueryBase { // Get normal protections for existing titles if ( count( $this->titles ) ) { $this->resetQueryParams(); - $this->addTables( array( 'page_restrictions', 'page' ) ); - $this->addWhere( 'page_id=pr_page' ); + $this->addTables( 'page_restrictions' ); $this->addFields( array( 'pr_page', 'pr_type', 'pr_level', - 'pr_expiry', 'pr_cascade', 'page_namespace', - 'page_title' ) ); + 'pr_expiry', 'pr_cascade' ) ); $this->addWhereFld( 'pr_page', array_keys( $this->titles ) ); $res = $this->select( __METHOD__ ); foreach ( $res as $row ) { + $title = $this->titles[$row->pr_page]; $a = array( 'type' => $row->pr_type, 'level' => $row->pr_level, @@ -446,11 +445,14 @@ class ApiQueryInfo extends ApiQueryBase { if ( $row->pr_cascade ) { $a['cascade'] = ''; } - $this->protections[$row->page_namespace][$row->page_title][] = $a; - - // Also check old restrictions - if ( $this->pageRestrictions[$row->pr_page] ) { - $restrictions = explode( ':', trim( $this->pageRestrictions[$row->pr_page] ) ); + $this->protections[$title->getNamespace()][$title->getDBkey()][] = $a; + } + // Also check old restrictions + foreach( $this->titles as $pageId => $title ) { + if ( $this->pageRestrictions[$pageId] ) { + $namespace = $title->getNamespace(); + $dbKey = $title->getDBkey(); + $restrictions = explode( ':', trim( $this->pageRestrictions[$pageId] ) ); foreach ( $restrictions as $restrict ) { $temp = explode( '=', trim( $restrict ) ); if ( count( $temp ) == 1 ) { @@ -460,12 +462,12 @@ class ApiQueryInfo extends ApiQueryBase { if ( $restriction == '' ) { continue; } - $this->protections[$row->page_namespace][$row->page_title][] = array( + $this->protections[$namespace][$dbKey][] = array( 'type' => 'edit', 'level' => $restriction, 'expiry' => 'infinity', ); - $this->protections[$row->page_namespace][$row->page_title][] = array( + $this->protections[$namespace][$dbKey][] = array( 'type' => 'move', 'level' => $restriction, 'expiry' => 'infinity', @@ -475,7 +477,7 @@ class ApiQueryInfo extends ApiQueryBase { if ( $restriction == '' ) { continue; } - $this->protections[$row->page_namespace][$row->page_title][] = array( + $this->protections[$namespace][$dbKey][] = array( 'type' => $temp[0], 'level' => $restriction, 'expiry' => 'infinity', -- 2.20.1