API: (bug 16629) "edit=:move=" in page.page_restrictions was interpreted incorrectly...
authorRoan Kattouw <catrope@users.mediawiki.org>
Mon, 12 Jan 2009 14:27:28 +0000 (14:27 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Mon, 12 Jan 2009 14:27:28 +0000 (14:27 +0000)
RELEASE-NOTES
includes/api/ApiQueryInfo.php

index d2e1cf3..8258d34 100644 (file)
@@ -41,6 +41,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 
 == API changes in 1.15 ==
 * (bug 16798) JSON encoding errors for some characters outside the BMP
+* (bug 16629) prop=info&inprop=protection lists empty legacy protections
+  incorrectly
 
 === Languages updated in 1.15 ===
 
index fe90f4c..062831c 100644 (file)
@@ -212,6 +212,38 @@ class ApiQueryInfo extends ApiQueryBase {
                                if($row->pr_cascade)
                                        $a['cascade'] = '';
                                $protections[$row->pr_page][] = $a;
+                               
+                               # Also check old restrictions
+                               if($pageRestrictions[$row->pr_page]) {
+                                       foreach(explode(':', trim($pageRestrictions[$pageid])) as $restrict) {
+                                               $temp = explode('=', trim($restrict));
+                                               if(count($temp) == 1) {
+                                                       // old old format should be treated as edit/move restriction
+                                                       $restriction = trim( $temp[0] );
+                                                       if($restriction == '')
+                                                               continue;
+                                                       $protections[$row->pr_page][] = array(
+                                                               'type' => 'edit',
+                                                               'level' => $restriction,
+                                                               'expiry' => 'infinity',
+                                                       );
+                                                       $protections[$row->pr_page][] = array(
+                                                               'type' => 'move',
+                                                               'level' => $restriction,
+                                                               'expiry' => 'infinity',
+                                                       );
+                                               } else {
+                                                       $restriction = trim( $temp[1] );
+                                                       if($restriction == '')
+                                                               continue;
+                                                       $protections[$row->pr_page][] = array(
+                                                               'type' => $temp[0],
+                                                               'level' => $restriction,
+                                                               'expiry' => 'infinity',
+                                                       );
+                                               }
+                                       }
+                               }
                        }
                        $db->freeResult($res);
                        
@@ -420,34 +452,6 @@ class ApiQueryInfo extends ApiQueryBase {
                                        $pageInfo['protection'] = $protections[$pageid];
                                        $result->setIndexedTagName($pageInfo['protection'], 'pr');
                                }
-                               # Also check old restrictions
-                               if( $pageRestrictions[$pageid] ) {
-                                       foreach( explode( ':', trim( $pageRestrictions[$pageid] ) ) as $restrict ) {
-                                               $temp = explode( '=', trim( $restrict ) );
-                                               if(count($temp) == 1) {
-                                                       // old old format should be treated as edit/move restriction
-                                                       $restriction = trim( $temp[0] );
-                                                       $pageInfo['protection'][] = array(
-                                                               'type' => 'edit',
-                                                               'level' => $restriction,
-                                                               'expiry' => 'infinity',
-                                                       );
-                                                       $pageInfo['protection'][] = array(
-                                                               'type' => 'move',
-                                                               'level' => $restriction,
-                                                               'expiry' => 'infinity',
-                                                       );
-                                               } else {
-                                                       $restriction = trim( $temp[1] );
-                                                       $pageInfo['protection'][] = array(
-                                                               'type' => $temp[0],
-                                                               'level' => $restriction,
-                                                               'expiry' => 'infinity',
-                                                       );
-                                               }
-                                       }
-                                       $result->setIndexedTagName($pageInfo['protection'], 'pr');
-                               }
                        }
                        if($fld_talkid && isset($talkids[$title->getNamespace()][$title->getDBKey()]))
                                $pageInfo['talkid'] = $talkids[$title->getNamespace()][$title->getDBKey()];