// More validation only when choices were not given
// choices were validated in parseMultiValue()
- if (!is_array($type) && isset ($value)) {
-
- switch ($type) {
- case 'NULL' : // nothing to do
- break;
- case 'string' : // nothing to do
- break;
- case 'integer' : // Force everything using intval()
- $value = is_array($value) ? array_map('intval', $value) : intval($value);
- break;
- case 'limit' :
- if (!isset ($paramSettings[self :: PARAM_MAX1]) || !isset ($paramSettings[self :: PARAM_MAX2]))
- ApiBase :: dieDebug(__METHOD__, "MAX1 or MAX2 are not defined for the limit $paramName");
- if ($multi)
- ApiBase :: dieDebug(__METHOD__, "Multi-values not supported for $paramName");
- $min = isset ($paramSettings[self :: PARAM_MIN]) ? $paramSettings[self :: PARAM_MIN] : 0;
- $value = intval($value);
- $this->validateLimit($paramName, $value, $min, $paramSettings[self :: PARAM_MAX1], $paramSettings[self :: PARAM_MAX2]);
- break;
- case 'boolean' :
- if ($multi)
- ApiBase :: dieDebug(__METHOD__, "Multi-values not supported for $paramName");
- break;
- case 'timestamp' :
- if ($multi)
- ApiBase :: dieDebug(__METHOD__, "Multi-values not supported for $paramName");
- if (!preg_match('/^[0-9]{14}$/', $value)) {
- $valueName = ""; // TODO: initialization
- $this->dieUsage("Invalid value '$value' for timestamp parameter $paramName", "badtimestamp_{$valueName}");
- }
- break;
- default :
- ApiBase :: dieDebug(__METHOD__, "Param $paramName's type is unknown - $type");
-
+ if (isset ($value)) {
+ if (!is_array($type)) {
+ switch ($type) {
+ case 'NULL' : // nothing to do
+ break;
+ case 'string' : // nothing to do
+ break;
+ case 'integer' : // Force everything using intval()
+ $value = is_array($value) ? array_map('intval', $value) : intval($value);
+ break;
+ case 'limit' :
+ if (!isset ($paramSettings[self :: PARAM_MAX1]) || !isset ($paramSettings[self :: PARAM_MAX2]))
+ ApiBase :: dieDebug(__METHOD__, "MAX1 or MAX2 are not defined for the limit $paramName");
+ if ($multi)
+ ApiBase :: dieDebug(__METHOD__, "Multi-values not supported for $paramName");
+ $min = isset ($paramSettings[self :: PARAM_MIN]) ? $paramSettings[self :: PARAM_MIN] : 0;
+ $value = intval($value);
+ $this->validateLimit($paramName, $value, $min, $paramSettings[self :: PARAM_MAX1], $paramSettings[self :: PARAM_MAX2]);
+ break;
+ case 'boolean' :
+ if ($multi)
+ ApiBase :: dieDebug(__METHOD__, "Multi-values not supported for $paramName");
+ break;
+ case 'timestamp' :
+ if ($multi)
+ ApiBase :: dieDebug(__METHOD__, "Multi-values not supported for $paramName");
+ $value = wfTimestamp(TS_UNIX, $value);
+ if ($value === 0)
+ $this->dieUsage("Invalid value '$value' for timestamp parameter $paramName", "badtimestamp_{$paramName}");
+ $value = wfTimestamp(TS_MW, $value);
+ break;
+ default :
+ ApiBase :: dieDebug(__METHOD__, "Param $paramName's type is unknown - $type");
+
+ }
}
- }
- // There should never be any duplicate values in a list
- if (is_array($value))
- $value = array_unique($value);
+ // There should never be any duplicate values in a list
+ if (is_array($value))
+ $value = array_unique($value);
+ }
return $value;
}
<br/>
<small>
You are looking at the HTML representation of the <?=$this->mFormat?> format.<br/>
-HTML is good for debugging, but probably not suitable for your application.<br/>
+HTML is good for debugging, but probably is not suitable for your application.<br/>
Please see "format" parameter documentation at the <a href='api.php'>API help</a>
for more information.
</small>
$feed->outFooter();
} else {
// Error has occured, print something usefull
- // TODO: make this error more informative using $this->dieDebug() or similar
+ // TODO: make this error more informative using ApiBase :: dieDebug() or similar
wfHttpError(500, 'Internal Server Error', '');
}
}
return __CLASS__ . ': $Id$';
}
}
-?>
\ No newline at end of file
+?>
*/
private function initFromQueryResult($db, $res, &$remaining = null, $processTitles = null) {
if (!is_null($remaining) && is_null($processTitles))
- $this->dieDebug('Missing $processTitles parameter when $remaining is provided');
+ ApiBase :: dieDebug('Missing $processTitles parameter when $remaining is provided');
while ($row = $db->fetchObject($res)) {
// Report any missing page ids
foreach ($pageSet->getMissingPageIDs() as $pageid) {
$pages[$pageid] = array (
- 'id' => $pageid,
+ 'pageid' => $pageid,
'missing' => ''
);
}
// Output general page information for found titles
foreach ($pageSet->getGoodTitles() as $pageid => $title) {
$pages[$pageid] = array (
- 'ns' => $title->getNamespace(), 'title' => $title->getPrefixedText(), 'id' => $pageid);
+ 'pageid' => $pageid, 'ns' => $title->getNamespace(), 'title' => $title->getPrefixedText());
}
if (!empty ($pages)) {
$db = $this->getDB();
$this->addTables('page');
- $this->addWhereIf('page_is_redirect = 1', $filterredir === 'redirects');
- $this->addWhereIf('page_is_redirect = 0', $filterredir === 'nonredirects');
+ if( !$this->addWhereIf('page_is_redirect = 1', $filterredir === 'redirects'))
+ $this->addWhereIf('page_is_redirect = 0', $filterredir === 'nonredirects');
$this->addWhereFld('page_namespace', $namespace);
if (isset ($from))
$this->addWhere('page_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($from)));
break;
}
- $title = Title :: makeTitle($row->page_namespace, $row->page_title);
- // skip any pages that user has no rights to read
- if ($title->userCanRead()) {
-
- if (is_null($resultPageSet)) {
- $id = intval($row->page_id);
- $data[$id] = array (
- 'id' => $id,
- 'ns' => $title->getNamespace(), 'title' => $title->getPrefixedText());
- } else {
+ if (is_null($resultPageSet)) {
+ $vals = $this->addRowInfo('page', $row);
+ if($vals)
+ $data[intval($row->page_id)] = $vals;
+ } else {
+ $title = Title :: makeTitle($row->page_namespace, $row->page_title);
+ // skip any pages that user has no rights to read
+ if ($title->userCanRead()) {
$resultPageSet->processDbRow($row);
}
}
return __CLASS__ . ': $Id$';
}
}
-?>
\ No newline at end of file
+?>
}
protected function addTables($value) {
- if(!is_array($this->tables))
- $this->dieDebug(__METHOD__, 'Must not call setTablesAsExpression() before this method');
if(is_array($value))
$this->tables = array_merge($this->tables, $value);
else
$this->tables[] = $value;
}
- protected function setTablesAsExpression($value) {
- if(!empty($this->tables))
- $this->dieDebug(__METHOD__, 'Must not call addTables() before this method');
- $this->tables = $value;
- }
-
protected function addFields($value) {
if(is_array($value))
$this->fields = array_merge($this->fields, $value);
}
protected function addFieldsIf($value, $condition) {
- if ($condition)
+ if ($condition) {
$this->addFields($value);
+ return true;
+ }
+ return false;
}
protected function addWhere($value) {
}
protected function addWhereIf($value, $condition) {
- if ($condition)
+ if ($condition) {
$this->addWhere($value);
+ return true;
+ }
+ return false;
}
protected function addWhereFld($field, $value) {
$this->addOption('ORDER BY', $field . ($isDirNewer ? '' : ' DESC'));
}
+ protected function addOption($name, $value) {
+ $this->options[$name] = $value;
+ }
+
protected function select($method) {
$this->profileDBIn();
$res = $this->getDB()->select($this->tables, $this->fields, $this->where, $method, $this->options);
return $res;
}
- protected function addOption($name, $value) {
- $this->options[$name] = $value;
+
+ protected function addRowInfo($prefix, $row) {
+
+ $vals = array();
+
+ // ID
+ @$tmp = $row->{$prefix . '_id'};
+ if(!is_null($tmp)) $vals[$prefix . 'id'] = intval($tmp);
+
+ // Title
+ $title = ApiQueryBase::addRowInfo_title($row, $prefix . '_namespace', $prefix . '_title');
+ if ($title) {
+ if (!$title->userCanRead())
+ return false;
+ $vals['ns'] = $title->getNamespace();
+ $vals['title'] = $title->getPrefixedText();
+ }
+
+ if ($prefix === 'rc') {
+
+ // PageId
+ @$tmp = $row->rc_cur_id;
+ if(!is_null($tmp)) $vals['pageid'] = intval($tmp);
+
+ @$tmp = $row->rc_this_oldid;
+ if(!is_null($tmp)) $vals['revid'] = intval($tmp);
+
+ @$tmp = $row->rc_last_oldid;
+ if(!is_null($tmp)) $vals['old_revid'] = intval($tmp);
+
+ $title = ApiQueryBase::addRowInfo_title($row, 'rc_moved_to_ns', 'rc_moved_to_title');
+ if ($title) {
+ if (!$title->userCanRead())
+ return false;
+ $vals['new_ns'] = $title->getNamespace();
+ $vals['new_title'] = $title->getPrefixedText();
+ }
+
+ @$tmp = $row->rc_patrolled;
+ if(!is_null($tmp)) $vals['patrolled'] = '';
+
+ } elseif ($prefix === 'log') {
+
+ // PageId
+ @$tmp = $row->page_id;
+ if(!is_null($tmp)) $vals['pageid'] = intval($tmp);
+
+ if ($row->log_params !== '') {
+ $params = explode("\n", $row->log_params);
+ if ($row->log_type == 'move' && isset ($params[0])) {
+ $newTitle = Title :: newFromText($params[0]);
+ if ($newTitle) {
+ $vals['new_ns'] = $newTitle->getNamespace();
+ $vals['new_title'] = $newTitle->getPrefixedText();
+ $params = null;
+ }
+ }
+
+ if (!empty ($params)) {
+ $this->getResult()->setIndexedTagName($params, 'param');
+ $vals = array_merge($vals, $params);
+ }
+ }
+
+ } elseif ($prefix === 'rev') {
+
+ // PageId
+ @$tmp = $row->rev_page;
+ if(!is_null($tmp)) $vals['pageid'] = intval($tmp);
+ }
+
+ // Type
+ @$tmp = $row->{$prefix . '_type'};
+ if(!is_null($tmp)) $vals['type'] = $tmp;
+
+ // Action
+ @$tmp = $row->{$prefix . '_action'};
+ if(!is_null($tmp)) $vals['action'] = $tmp;
+
+ // Old ID
+ @$tmp = $row->{$prefix . '_text_id'};
+ if(!is_null($tmp)) $vals['oldid'] = intval($tmp);
+
+ // User Name / Anon IP
+ @$tmp = $row->{$prefix . '_user_text'};
+ if(is_null($tmp)) @$tmp = $row->user_name;
+ if(!is_null($tmp)) {
+ $vals['user'] = $tmp;
+ @$tmp = !$row->{$prefix . '_user'};
+ if(!is_null($tmp) && $tmp)
+ $vals['anon'] = '';
+ }
+
+ // Bot Edit
+ @$tmp = $row->{$prefix . '_bot'};
+ if(!is_null($tmp) && $tmp) $vals['bot'] = '';
+
+ // New Edit
+ @$tmp = $row->{$prefix . '_new'};
+ if(is_null($tmp)) @$tmp = $row->{$prefix . '_is_new'};
+ if(!is_null($tmp) && $tmp) $vals['new'] = '';
+
+ // Minor Edit
+ @$tmp = $row->{$prefix . '_minor_edit'};
+ if(is_null($tmp)) @$tmp = $row->{$prefix . '_minor'};
+ if(!is_null($tmp) && $tmp) $vals['minor'] = '';
+
+ // Timestamp
+ @$tmp = $row->{$prefix . '_timestamp'};
+ if(!is_null($tmp))
+ $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $tmp);
+
+ // Comment
+ @$tmp = $row->{$prefix . '_comment'};
+ if(!empty($tmp)) // optimize bandwidth
+ $vals['comment'] = $tmp;
+
+ return $vals;
+ }
+
+ private static function addRowInfo_title($row, $nsfld, $titlefld) {
+ @$ns = $row->$nsfld;
+ if(!is_null($ns)) {
+ @$title = $row->$titlefld;
+ if(!empty($title))
+ return Title :: makeTitle($ns, $title);
+ }
+ return false;
}
-
+
/**
* Override this method to request extra fields from the pageSet
* using $this->getPageSet()->requestField('fieldName')
*/
public abstract function executeGenerator($resultPageSet);
}
-?>
\ No newline at end of file
+?>
foreach ($titles as $pageid => $title) {
$pageInfo = array (
'touched' => $pageTouched[$pageid],
- 'lastrevid' => $pageLatest[$pageid]
+ 'lastrevid' => intval($pageLatest[$pageid])
);
if ($pageIsRedir[$pageid])
return __CLASS__ . ': $Id$';
}
}
-?>
\ No newline at end of file
+?>
$db = $this->getDB();
extract($db->tableNames('logging', 'page', 'user'), EXTR_PREFIX_ALL, 'tbl');
- $this->setTablesAsExpression("$tbl_logging LEFT OUTER JOIN $tbl_page ON " .
+ $this->addTables("$tbl_logging LEFT OUTER JOIN $tbl_page ON " .
"log_namespace=page_namespace AND log_title=page_title " .
"INNER JOIN $tbl_user ON user_id=log_user");
break;
}
- $vals = array (
- 'action' => "$row->log_type/$row->log_action",
- 'timestamp' => $row->log_timestamp,
- 'comment' => $row->log_comment,
- 'pageid' => intval($row->page_id
- ));
-
- $title = Title :: makeTitle($row->log_namespace, $row->log_title);
- $vals['ns'] = $title->getNamespace();
- $vals['title'] = $title->getPrefixedText();
-
- if ($row->log_params !== '') {
- $params = explode("\n", $row->log_params);
- if ($row->log_type == 'move' && isset ($params[0])) {
- $destTitle = Title :: newFromText($params[0]);
- if ($destTitle) {
- $vals['tons'] = $destTitle->getNamespace();
- $vals['totitle'] = $destTitle->getPrefixedText();
- $params = null;
- }
- }
-
- if (!empty ($params)) {
- $this->getResult()->setIndexedTagName($params, 'param');
- $vals = array_merge($vals, $params);
- }
- }
-
- if (!$row->log_user)
- $vals['anon'] = '';
- $vals['user'] = $row->user_name;
-
- $data[] = $vals;
+ $vals = $this->addRowInfo('log', $row);
+ if($vals)
+ $data[] = $vals;
}
$db->freeResult($res);
return __CLASS__ . ': $Id$';
}
}
-?>
\ No newline at end of file
+?>
}
public function execute() {
- $limit = $from = $namespace = $hide = $dir = $start = $end = null;
+ $limit = $prop = $from = $namespace = $hide = $dir = $start = $end = null;
extract($this->extractRequestParams());
$this->addTables('recentchanges');
if (!is_null($hide)) {
$hide = array_flip($hide);
+ if(isset ($hide['anons']) && isset ($hide['liu']))
+ $this->dieUsage( "Both 'anons' and 'liu' cannot be set at the same time", 'hide' );
$this->addWhereIf('rc_minor = 0', isset ($hide['minor']));
$this->addWhereIf('rc_bot = 0', isset ($hide['bots']));
$this->addWhereIf('rc_user != 0', isset ($hide['anons']));
$this->addFields(array (
'rc_timestamp',
- 'rc_user',
- 'rc_user_text',
'rc_namespace',
'rc_title',
- 'rc_comment',
- 'rc_minor',
- 'rc_bot',
- 'rc_new',
'rc_cur_id',
'rc_this_oldid',
'rc_last_oldid',
'rc_moved_to_title'
));
+ if (!is_null($prop)) {
+ $prop = array_flip($prop);
+ $this->addFieldsIf('rc_comment', isset ($prop['comment']));
+ if (isset ($prop['user'])) {
+ $this->addFields('rc_user');
+ $this->addFields('rc_user_text');
+ }
+ if (isset ($prop['flags'])) {
+ $this->addFields('rc_minor');
+ $this->addFields('rc_bot');
+ $this->addFields('rc_new');
+ }
+ }
+
$this->addOption('LIMIT', $limit +1);
$data = array ();
break;
}
- $title = Title :: makeTitle($row->rc_namespace, $row->rc_title);
- // skip any pages that user has no rights to read
- if ($title->userCanRead()) {
-
- $id = intval($row->rc_cur_id);
- $data[] = array (
- 'id' => $id,
- 'ns' => $title->getNamespace(), 'title' => $title->getPrefixedText(),
- 'timestamp' => $row->rc_timestamp,
- 'user' => $row->rc_user_text,
- 'comment' => $row->rc_comment,
- 'this_oldid' => $row->rc_this_oldid,
- 'last_oldid' => $row->rc_last_oldid,
- 'type' => $row->rc_type,
- 'moved_to_ns' => $row->rc_moved_to_ns,
- 'moved_to_title' => $row->rc_moved_to_title);
-
- if (!$row->rc_user)
- $vals['anon'] = '';
- if ($row->rc_new)
- $vals['new'] = '';
- if ($row->rc_bot)
- $vals['bot'] = '';
- if ($row->rc_minor)
- $vals['minor'] = '';
- }
+ $vals = $this->addRowInfo('rc', $row);
+ if($vals)
+ $data[] = $vals;
}
$db->freeResult($res);
ApiBase :: PARAM_DFLT => 0,
ApiBase :: PARAM_TYPE => $namespaces
),
+ 'prop' => array (
+ ApiBase :: PARAM_ISMULTI => true,
+ ApiBase :: PARAM_TYPE => array (
+ 'user',
+ 'comment',
+ 'flags'
+ )
+ ),
'hide' => array (
ApiBase :: PARAM_ISMULTI => true,
ApiBase :: PARAM_TYPE => array (
$limit = $startid = $endid = $start = $end = $dir = $prop = null;
extract($this->extractRequestParams());
- $db = $this->getDB();
-
- // true when ordered by timestamp from older to newer, false otherwise
- $dirNewer = ($dir === 'newer');
-
// If any of those parameters are used, work in 'enumeration' mode.
// Enum mode can only be used when exactly one page is provided.
// Enumerating revisions on multiple pages make it extremelly
// difficult to manage continuations and require additional sql indexes
- $enumRevMode = (!is_null($limit) || !is_null($startid) || !is_null($endid) || $dirNewer || !is_null($start) || !is_null($end));
+ $enumRevMode = (!is_null($limit) || !is_null($startid) || !is_null($endid) || $dir === 'newer' || !is_null($start) || !is_null($end));
$pageSet = $this->getPageSet();
$pageCount = $pageSet->getGoodTitleCount();
if ($pageCount > 1 && $enumRevMode)
$this->dieUsage('titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, start, and end parameters may only be used on a single page.', 'multpages');
- $tables = array (
- 'revision'
- );
- $fields = array (
+ $this->addTables('revision');
+ $this->addFields(array (
'rev_id',
'rev_page',
'rev_text_id',
'rev_minor_edit'
- );
- $where = array (
- 'rev_deleted' => 0
- );
- $options = array ();
+ ));
+ $this->addWhere('rev_deleted=0');
+
+ $showContent = false;
- $showTimestamp = $showUser = $showComment = $showContent = false;
if (!is_null($prop)) {
- foreach ($prop as $p) {
- switch ($p) {
- case 'timestamp' :
- $fields[] = 'rev_timestamp';
- $showTimestamp = true;
- break;
- case 'user' :
- $fields[] = 'rev_user';
- $fields[] = 'rev_user_text';
- $showUser = true;
- break;
- case 'comment' :
- $fields[] = 'rev_comment';
- $showComment = true;
- break;
- case 'content' :
- $tables[] = 'text';
- $where[] = 'rev_text_id=old_id';
- $fields[] = 'old_id';
- $fields[] = 'old_text';
- $fields[] = 'old_flags';
- $showContent = true;
- break;
- default :
- ApiBase :: dieDebug(__METHOD__, "unknown prop $p");
- }
+ $prop = array_flip($prop);
+ $this->addFieldsIf('rev_timestamp', isset ($prop['timestamp']));
+ $this->addFieldsIf('rev_comment', isset ($prop['comment']));
+ if (isset ($prop['user'])) {
+ $this->addFields('rev_user');
+ $this->addFields('rev_user_text');
+ }
+ if (isset ($prop['content'])) {
+ $this->addTables('text');
+ $this->addWhere('rev_text_id=old_id');
+ $this->addFields('old_id');
+ $this->addFields('old_text');
+ $this->addFields('old_flags');
+ $showContent = true;
}
}
// Switching to rev_id removes the potential problem of having more than
// one row with the same timestamp for the same page.
// The order needs to be the same as start parameter to avoid SQL filesort.
- $options['ORDER BY'] = (!is_null($startid) ? 'rev_id' : 'rev_timestamp') . ($dirNewer ? '' : ' DESC');
- $before = ($dirNewer ? '<=' : '>=');
- $after = ($dirNewer ? '>=' : '<=');
-
- if (!is_null($startid))
- $where[] = 'rev_id' . $after . intval($startid);
- if (!is_null($endid))
- $where[] = 'rev_id' . $before . intval($endid);
- if (!is_null($start))
- $where[] = 'rev_timestamp' . $after . $db->addQuotes($start);
- if (!is_null($end))
- $where[] = 'rev_timestamp' . $before . $db->addQuotes($end);
+ if (is_null($startid))
+ $this->addWhereRange('rev_id', $dir, $startid, $endid);
+ else
+ $this->addWhereRange('rev_timestamp', $dir, $start, $end);
// must manually initialize unset limit
if (is_null($limit))
$limit = 10;
-
$this->validateLimit($this->encodeParamName('limit'), $limit, 1, $userMax, $botMax);
// There is only one ID, use it
- $where['rev_page'] = array_pop(array_keys($pageSet->getGoodTitles()));
-
+ $this->addWhereFld('rev_page', array_pop(array_keys($pageSet->getGoodTitles())));
}
elseif ($pageCount > 0) {
// When working in multi-page non-enumeration mode,
// limit to the latest revision only
- $tables[] = 'page';
- $where[] = 'page_id=rev_page';
- $where[] = 'page_latest=rev_id';
+ $this->addTables('page');
+ $this->addWhere('page_id=rev_page');
+ $this->addWhere('page_latest=rev_id');
$this->validateLimit('page_count', $pageCount, 1, $userMax, $botMax);
// Get all page IDs
- $where['page_id'] = array_keys($pageSet->getGoodTitles());
+ $this->addWhereFld('page_id', array_keys($pageSet->getGoodTitles()));
$limit = $pageCount; // assumption testing -- we should never get more then $pageCount rows.
}
$this->validateLimit('rev_count', $revCount, 1, $userMax, $botMax);
// Get all revision IDs
- $where['rev_id'] = array_keys($pageSet->getRevisionIDs());
+ $this->addWhereFld('rev_id', array_keys($pageSet->getRevisionIDs()));
$limit = $revCount; // assumption testing -- we should never get more then $revCount rows.
} else
ApiBase :: dieDebug(__METHOD__, 'param validation?');
- $options['LIMIT'] = $limit +1;
-
- $this->profileDBIn();
- $res = $db->select($tables, $fields, $where, __METHOD__, $options);
- $this->profileDBOut();
+ $this->addOption('LIMIT', $limit +1);
$data = array ();
$count = 0;
+ $db = $this->getDB();
+ $res = $this->select(__METHOD__);
while ($row = $db->fetchObject($res)) {
if (++ $count > $limit) {
break;
}
- $vals = array (
- 'revid' => intval($row->rev_id
- ), 'oldid' => intval($row->rev_text_id));
-
- if ($row->rev_minor_edit) {
- $vals['minor'] = '';
- }
-
- if ($showTimestamp)
- $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rev_timestamp);
+ $vals = $this->addRowInfo('rev', $row);
+ if ($vals) {
+ if ($showContent)
+ ApiResult :: setContent($vals, Revision :: getRevisionText($row));
- if ($showUser) {
- $vals['user'] = $row->rev_user_text;
- if (!$row->rev_user)
- $vals['anon'] = '';
+ $this->getResult()->addValue(array (
+ 'query',
+ 'pages',
+ intval($row->rev_page
+ ), 'revisions'), intval($row->rev_id), $vals);
}
-
- if ($showComment)
- $vals['comment'] = $row->rev_comment;
-
- if ($showContent) {
- ApiResult :: setContent($vals, Revision :: getRevisionText($row));
- }
-
- $this->getResult()->addValue(array (
- 'query',
- 'pages',
- intval($row->rev_page
- ), 'revisions'), intval($row->rev_id), $vals);
}
$db->freeResult($res);
// Ensure that all revisions are shown as '<rev>' elements
$result = $this->getResult();
- if( $result->getIsRawMode()) {
+ if ($result->getIsRawMode()) {
$data = & $result->getData();
foreach ($data['query']['pages'] as & $page) {
if (is_array($page) && array_key_exists('revisions', $page)) {
return __CLASS__ . ': $Id$';
}
}
-?>
\ No newline at end of file
+?>
if (is_null($resultPageSet)) {
$this->addFields(array (
- 'rc_cur_id AS page_id',
- 'rc_this_oldid AS rev_id',
- 'rc_namespace AS page_namespace',
- 'rc_title AS page_title',
- 'rc_new AS page_is_new',
- 'rc_minor AS rev_minor_edit',
- 'rc_timestamp AS rev_timestamp'
+ 'rc_cur_id',
+ 'rc_this_oldid',
+ 'rc_namespace',
+ 'rc_title',
+ 'rc_new',
+ 'rc_minor',
+ 'rc_timestamp'
));
- $this->addFieldsIf('rc_user AS rev_user', $user);
- $this->addFieldsIf('rc_user_text AS rev_user_text', $user);
- $this->addFieldsIf('rc_comment AS rev_comment', $comment);
+ $this->addFieldsIf('rc_user', $user);
+ $this->addFieldsIf('rc_user_text', $user);
+ $this->addFieldsIf('rc_comment', $comment);
$this->addFieldsIf('rc_patrolled', $patrol);
}
elseif ($allrev) {
$this->addFields(array (
- 'rc_this_oldid AS rev_id',
- 'rc_namespace AS page_namespace',
- 'rc_title AS page_title',
- 'rc_timestamp AS rev_timestamp'
+ 'rc_this_oldid',
+ 'rc_namespace',
+ 'rc_title',
+ 'rc_timestamp'
));
} else {
$this->addFields(array (
- 'rc_cur_id AS page_id',
- 'rc_namespace AS page_namespace',
- 'rc_title AS page_title',
- 'rc_timestamp AS rev_timestamp'
+ 'rc_cur_id',
+ 'rc_namespace',
+ 'rc_title',
+ 'rc_timestamp'
));
}
$this->addWhereFld('wl_namespace', $namespace);
$this->addWhereIf('rc_this_oldid=page_latest', !$allrev);
$this->addWhereIf("rc_timestamp > ''", !isset ($start) && !isset ($end));
-
+
$this->addOption('LIMIT', $limit +1);
$data = array ();
while ($row = $db->fetchObject($res)) {
if (++ $count > $limit) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
- $this->setContinueEnumParameter('from', $row->rev_timestamp);
+ $this->setContinueEnumParameter('from', $row->rc_timestamp);
break;
}
- $title = Title :: makeTitle($row->page_namespace, $row->page_title);
- // skip any pages that user has no rights to read
- if ($title->userCanRead()) {
-
- if (is_null($resultPageSet)) {
- $vals = array ();
- $vals['pageid'] = intval($row->page_id);
- $vals['revid'] = intval($row->rev_id);
- $vals['ns'] = $title->getNamespace();
- $vals['title'] = $title->getPrefixedText();
-
- if ($row->page_is_new)
- $vals['new'] = '';
- if ($row->rev_minor_edit)
- $vals['minor'] = '';
-
- if ($user) {
- if (!$row->rev_user)
- $vals['anon'] = '';
- $vals['user'] = $row->rev_user_text;
- }
- if ($comment)
- $vals['comment'] = $row->rev_comment;
- if ($timestamp)
- $vals['timestamp'] = $row->rev_timestamp;
- if ($patrol && $row->rc_patrolled)
- $vals['patrolled'] = '';
-
+ if (is_null($resultPageSet)) {
+ $vals = $this->addRowInfo('rc', $row);
+ if($vals)
$data[] = $vals;
- }
- elseif ($allrev) {
- $data[] = intval($row->rev_id);
- } else {
- $data[] = intval($row->page_id);
+ } else {
+ $title = Title :: makeTitle($row->rc_namespace, $row->rc_title);
+ // skip any pages that user has no rights to read
+ if ($title->userCanRead()) {
+ if ($allrev) {
+ $data[] = intval($row->rc_this_oldid);
+ } else {
+ $data[] = intval($row->rc_cur_id);
+ }
}
}
}
+
$db->freeResult($res);
if (is_null($resultPageSet)) {
return __CLASS__ . ': $Id$';
}
}
-?>
\ No newline at end of file
+?>