r23052 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23051‎ | r23052 | r23053 >
Date:02:00, 18 June 2007
Author:yurik
Status:old
Tags:
Comment:
API: enh 10260: Added page protection status query in prop=info. Applied modified patch from Roan Kattouw.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Block.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryInfo.php
@@ -36,7 +36,7 @@
3737 class ApiQueryInfo extends ApiQueryBase {
3838
3939 public function __construct($query, $moduleName) {
40 - parent :: __construct($query, $moduleName);
 40+ parent :: __construct($query, $moduleName, 'in');
4141 }
4242
4343 public function requestExtraData($pageSet) {
@@ -50,6 +50,13 @@
5151
5252 public function execute() {
5353
 54+ $params = $this->extractRequestParams();
 55+ $fld_protection = false;
 56+ if(!is_null($params['prop'])) {
 57+ $prop = array_flip($params['prop']);
 58+ $fld_protection = isset($prop['protection']);
 59+ }
 60+
5461 $pageSet = $this->getPageSet();
5562 $titles = $pageSet->getGoodTitles();
5663 $result = $this->getResult();
@@ -61,6 +68,23 @@
6269 $pageLatest = $pageSet->getCustomField('page_latest');
6370 $pageLength = $pageSet->getCustomField('page_len');
6471
 72+ if ($fld_protection) {
 73+ $this->addTables('page_restrictions');
 74+ $this->addFields(array('pr_page', 'pr_type', 'pr_level', 'pr_expiry'));
 75+ $this->addWhereFld('pr_page', array_keys($titles));
 76+
 77+ $db = $this->getDB();
 78+ $res = $this->select(__METHOD__);
 79+ while($row = $db->fetchObject($res)) {
 80+ $protections[$row->pr_page][] = array(
 81+ 'type' => $row->pr_type,
 82+ 'level' => $row->pr_level,
 83+ 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 )
 84+ );
 85+ }
 86+ $db->freeResult($res);
 87+ }
 88+
6589 foreach ( $titles as $pageid => $unused ) {
6690 $pageInfo = array (
6791 'touched' => wfTimestamp(TS_ISO_8601, $pageTouched[$pageid]),
@@ -75,6 +99,15 @@
76100 if ($pageIsNew[$pageid])
77101 $pageInfo['new'] = '';
78102
 103+ if($fld_protection) {
 104+ if (isset($protections[$pageid])) {
 105+ $pageInfo['protection'] = $protections[$pageid];
 106+ $result->setIndexedTagName($pageInfo['protection'], 'pr');
 107+ } else {
 108+ $pageInfo['protection'] = array();
 109+ }
 110+ }
 111+
79112 $result->addValue(array (
80113 'query',
81114 'pages'
@@ -82,13 +115,35 @@
83116 }
84117 }
85118
 119+ protected function getAllowedParams() {
 120+ return array (
 121+ 'prop' => array (
 122+ ApiBase :: PARAM_DFLT => NULL,
 123+ ApiBase :: PARAM_ISMULTI => true,
 124+ ApiBase :: PARAM_TYPE => array (
 125+ 'protection'
 126+ ))
 127+ );
 128+ }
 129+
 130+ protected function getParamDescription() {
 131+ return array (
 132+ 'prop' => array (
 133+ 'Which additional properties to get:',
 134+ ' "protection" - List the protection level of each page'
 135+ )
 136+ );
 137+ }
 138+
 139+
86140 protected function getDescription() {
87141 return 'Get basic page information such as namespace, title, last touched date, ...';
88142 }
89143
90144 protected function getExamples() {
91145 return array (
92 - 'api.php?action=query&prop=info&titles=Main%20Page'
 146+ 'api.php?action=query&prop=info&titles=Main%20Page',
 147+ 'api.php?action=query&prop=info&inprop=protection&titles=Main%20Page'
93148 );
94149 }
95150
Index: trunk/phase3/includes/Block.php
@@ -628,11 +628,11 @@
629629 /**
630630 * Decode expiry which has come from the DB
631631 */
632 - static function decodeExpiry( $expiry ) {
 632+ static function decodeExpiry( $expiry, $timestampType = TS_MW ) {
633633 if ( $expiry == '' || $expiry == Block::infinity() ) {
634634 return Block::infinity();
635635 } else {
636 - return wfTimestamp( TS_MW, $expiry );
 636+ return wfTimestamp( $timestampType, $expiry );
637637 }
638638 }
639639
Index: trunk/phase3/RELEASE-NOTES
@@ -209,6 +209,7 @@
210210 * (bug 10147) Now interwiki titles are not processed but added to a separate
211211 "interwiki" section of the output.
212212 * Added categorymembers list to query for pages in a category.
 213+* (bug 10260) Show page protection status
213214
214215 == Maintenance script changes since 1.10 ==
215216

Follow-up revisions

RevisionCommit summaryAuthorDate
r23087Merged revisions 23050-23086 via svnmerge from...david03:14, 19 June 2007

Status & tagging log