From: Roan Kattouw Date: Mon, 12 Jan 2009 14:27:28 +0000 (+0000) Subject: API: (bug 16629) "edit=:move=" in page.page_restrictions was interpreted incorrectly... X-Git-Tag: 1.31.0-rc.0~43454 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=c0cd843e63c657345cbb93cad7b37286a0c2aafe;p=lhc%2Fweb%2Fwiklou.git API: (bug 16629) "edit=:move=" in page.page_restrictions was interpreted incorrectly. Also moved up the code checking for legacy protections to right after the code checking for 'new' protections. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d2e1cf3a0b..8258d34d70 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index fe90f4c93b..062831c028 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -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()];