Merge "Making listToText() not break if passed a 1-item list."
[lhc/web/wiklou.git] / includes / api / ApiQueryInfo.php
index 95c6bda..4a85b0b 100644 (file)
@@ -435,15 +435,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,
@@ -452,11 +451,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 ) {
@@ -466,12 +468,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',
@@ -481,7 +483,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',