本文整理汇总了PHP中Revision::selectPageFields方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::selectPageFields方法的具体用法?PHP Revision::selectPageFields怎么用?PHP Revision::selectPageFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::selectPageFields方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populateSearchIndex
/**
* Populates the search index with content from all pages
*/
protected function populateSearchIndex()
{
$res = $this->db->select('page', 'MAX(page_id) AS count');
$s = $this->db->fetchObject($res);
$count = $s->count;
$this->output("Rebuilding index fields for {$count} pages...\n");
$n = 0;
$fields = array_merge(Revision::selectPageFields(), Revision::selectFields(), Revision::selectTextFields());
while ($n < $count) {
if ($n) {
$this->output($n . "\n");
}
$end = $n + self::RTI_CHUNK_SIZE - 1;
$res = $this->db->select(['page', 'revision', 'text'], $fields, ["page_id BETWEEN {$n} AND {$end}", 'page_latest = rev_id', 'rev_text_id = old_id'], __METHOD__);
foreach ($res as $s) {
try {
$title = Title::makeTitle($s->page_namespace, $s->page_title);
$rev = new Revision($s);
$content = $rev->getContent();
$u = new SearchUpdate($s->page_id, $title, $content);
$u->doUpdate();
} catch (MWContentSerializationException $ex) {
$this->output("Failed to deserialize content of revision {$s->rev_id} of page " . "`" . $title->getPrefixedDBkey() . "`!\n");
}
}
$n += self::RTI_CHUNK_SIZE;
}
}
示例2: run
/**
* @param ApiPageSet $resultPageSet
* @return void
*/
protected function run(ApiPageSet $resultPageSet = null)
{
$db = $this->getDB();
$params = $this->extractRequestParams(false);
$result = $this->getResult();
$this->requireMaxOneParameter($params, 'user', 'excludeuser');
// Namespace check is likely to be desired, but can't be done
// efficiently in SQL.
$miser_ns = null;
$needPageTable = false;
if ($params['namespace'] !== null) {
$params['namespace'] = array_unique($params['namespace']);
sort($params['namespace']);
if ($params['namespace'] != MWNamespace::getValidNamespaces()) {
$needPageTable = true;
if ($this->getConfig()->get('MiserMode')) {
$miser_ns = $params['namespace'];
} else {
$this->addWhere(array('page_namespace' => $params['namespace']));
}
}
}
$this->addTables('revision');
if ($resultPageSet === null) {
$this->parseParameters($params);
$this->addTables('page');
$this->addJoinConds(array('page' => array('INNER JOIN', array('rev_page = page_id'))));
$this->addFields(Revision::selectFields());
$this->addFields(Revision::selectPageFields());
// Review this depeneding on the outcome of T113901
$this->addOption('STRAIGHT_JOIN');
} else {
$this->limit = $this->getParameter('limit') ?: 10;
$this->addFields(array('rev_timestamp', 'rev_id'));
if ($params['generatetitles']) {
$this->addFields(array('rev_page'));
}
if ($needPageTable) {
$this->addTables('page');
$this->addJoinConds(array('page' => array('INNER JOIN', array('rev_page = page_id'))));
$this->addFieldsIf(array('page_namespace'), (bool) $miser_ns);
// Review this depeneding on the outcome of T113901
$this->addOption('STRAIGHT_JOIN');
}
}
if ($this->fld_tags) {
$this->addTables('tag_summary');
$this->addJoinConds(array('tag_summary' => array('LEFT JOIN', array('rev_id=ts_rev_id'))));
$this->addFields('ts_tags');
}
if ($this->fetchContent) {
$this->addTables('text');
$this->addJoinConds(array('text' => array('INNER JOIN', array('rev_text_id=old_id'))));
$this->addFields('old_id');
$this->addFields(Revision::selectTextFields());
}
if ($params['user'] !== null) {
$id = User::idFromName($params['user']);
if ($id) {
$this->addWhereFld('rev_user', $id);
} else {
$this->addWhereFld('rev_user_text', $params['user']);
}
} elseif ($params['excludeuser'] !== null) {
$id = User::idFromName($params['excludeuser']);
if ($id) {
$this->addWhere('rev_user != ' . $id);
} else {
$this->addWhere('rev_user_text != ' . $db->addQuotes($params['excludeuser']));
}
}
if ($params['user'] !== null || $params['excludeuser'] !== null) {
// Paranoia: avoid brute force searches (bug 17342)
if (!$this->getUser()->isAllowed('deletedhistory')) {
$bitmask = Revision::DELETED_USER;
} elseif (!$this->getUser()->isAllowedAny('suppressrevision', 'viewsuppressed')) {
$bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
} else {
$bitmask = 0;
}
if ($bitmask) {
$this->addWhere($db->bitAnd('rev_deleted', $bitmask) . " != {$bitmask}");
}
}
$dir = $params['dir'];
if ($params['continue'] !== null) {
$op = $dir == 'newer' ? '>' : '<';
$cont = explode('|', $params['continue']);
$this->dieContinueUsageIf(count($cont) != 2);
$ts = $db->addQuotes($db->timestamp($cont[0]));
$rev_id = (int) $cont[1];
$this->dieContinueUsageIf(strval($rev_id) !== $cont[1]);
$this->addWhere("rev_timestamp {$op} {$ts} OR " . "(rev_timestamp = {$ts} AND " . "rev_id {$op}= {$rev_id})");
}
$this->addOption('LIMIT', $this->limit + 1);
$sort = $dir == 'newer' ? '' : ' DESC';
//.........这里部分代码省略.........
示例3: execute
public function execute()
{
$params = $this->extractRequestParams(false);
// 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 extremely
// difficult to manage continuations and require additional SQL indexes
$enumRevMode = !is_null($params['user']) || !is_null($params['excludeuser']) || !is_null($params['limit']) || !is_null($params['startid']) || !is_null($params['endid']) || $params['dir'] === 'newer' || !is_null($params['start']) || !is_null($params['end']);
$pageSet = $this->getPageSet();
$pageCount = $pageSet->getGoodTitleCount();
$revCount = $pageSet->getRevisionCount();
// Optimization -- nothing to do
if ($revCount === 0 && $pageCount === 0) {
return;
}
if ($revCount > 0 && $enumRevMode) {
$this->dieUsage('The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).', 'revids');
}
if ($pageCount > 1 && $enumRevMode) {
$this->dieUsage('titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.', 'multpages');
}
if (!is_null($params['difftotext'])) {
$this->difftotext = $params['difftotext'];
} elseif (!is_null($params['diffto'])) {
if ($params['diffto'] == 'cur') {
$params['diffto'] = 0;
}
if ((!ctype_digit($params['diffto']) || $params['diffto'] < 0) && $params['diffto'] != 'prev' && $params['diffto'] != 'next') {
$this->dieUsage('rvdiffto must be set to a non-negative number, "prev", "next" or "cur"', 'diffto');
}
// Check whether the revision exists and is readable,
// DifferenceEngine returns a rather ambiguous empty
// string if that's not the case
if ($params['diffto'] != 0) {
$difftoRev = Revision::newFromID($params['diffto']);
if (!$difftoRev) {
$this->dieUsageMsg(array('nosuchrevid', $params['diffto']));
}
if ($difftoRev->isDeleted(Revision::DELETED_TEXT)) {
$this->setWarning("Couldn't diff to r{$difftoRev->getID()}: content is hidden");
$params['diffto'] = null;
}
}
$this->diffto = $params['diffto'];
}
$db = $this->getDB();
$this->addTables('page');
$this->addFields(Revision::selectFields());
$this->addWhere('page_id = rev_page');
$prop = array_flip($params['prop']);
// Optional fields
$this->fld_ids = isset($prop['ids']);
// $this->addFieldsIf('rev_text_id', $this->fld_ids); // should this be exposed?
$this->fld_flags = isset($prop['flags']);
$this->fld_timestamp = isset($prop['timestamp']);
$this->fld_comment = isset($prop['comment']);
$this->fld_parsedcomment = isset($prop['parsedcomment']);
$this->fld_size = isset($prop['size']);
$this->fld_sha1 = isset($prop['sha1']);
$this->fld_userid = isset($prop['userid']);
$this->fld_user = isset($prop['user']);
$this->token = $params['token'];
// Possible indexes used
$index = array();
$userMax = $this->fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1;
$botMax = $this->fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2;
$limit = $params['limit'];
if ($limit == 'max') {
$limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
$this->getResult()->setParsedLimit($this->getModuleName(), $limit);
}
if (!is_null($this->token) || $pageCount > 0) {
$this->addFields(Revision::selectPageFields());
}
if (isset($prop['tags'])) {
$this->fld_tags = true;
$this->addTables('tag_summary');
$this->addJoinConds(array('tag_summary' => array('LEFT JOIN', array('rev_id=ts_rev_id'))));
$this->addFields('ts_tags');
}
if (!is_null($params['tag'])) {
$this->addTables('change_tag');
$this->addJoinConds(array('change_tag' => array('INNER JOIN', array('rev_id=ct_rev_id'))));
$this->addWhereFld('ct_tag', $params['tag']);
global $wgOldChangeTagsIndex;
$index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
}
if (isset($prop['content']) || !is_null($this->difftotext)) {
// For each page we will request, the user must have read rights for that page
foreach ($pageSet->getGoodTitles() as $title) {
if (!$title->userCan('read')) {
$this->dieUsage('The current user is not allowed to read ' . $title->getPrefixedText(), 'accessdenied');
}
}
$this->addTables('text');
$this->addWhere('rev_text_id=old_id');
$this->addFields('old_id');
$this->addFields(Revision::selectTextFields());
$this->fld_content = isset($prop['content']);
$this->expandTemplates = $params['expandtemplates'];
//.........这里部分代码省略.........
示例4: run
protected function run(ApiPageSet $resultPageSet = null)
{
$params = $this->extractRequestParams(false);
// 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 extremely
// difficult to manage continuations and require additional SQL indexes
$enumRevMode = !is_null($params['user']) || !is_null($params['excludeuser']) || !is_null($params['limit']) || !is_null($params['startid']) || !is_null($params['endid']) || $params['dir'] === 'newer' || !is_null($params['start']) || !is_null($params['end']);
$pageSet = $this->getPageSet();
$pageCount = $pageSet->getGoodTitleCount();
$revCount = $pageSet->getRevisionCount();
// Optimization -- nothing to do
if ($revCount === 0 && $pageCount === 0) {
// Nothing to do
return;
}
if ($revCount > 0 && count($pageSet->getLiveRevisionIDs()) === 0) {
// We're in revisions mode but all given revisions are deleted
return;
}
if ($revCount > 0 && $enumRevMode) {
$this->dieUsage('The revids= parameter may not be used with the list options ' . '(limit, startid, endid, dirNewer, start, end).', 'revids');
}
if ($pageCount > 1 && $enumRevMode) {
$this->dieUsage('titles, pageids or a generator was used to supply multiple pages, ' . 'but the limit, startid, endid, dirNewer, user, excludeuser, start ' . 'and end parameters may only be used on a single page.', 'multpages');
}
// In non-enum mode, rvlimit can't be directly used. Use the maximum
// allowed value.
if (!$enumRevMode) {
$this->setParsedLimit = false;
$params['limit'] = 'max';
}
$db = $this->getDB();
$this->addTables(array('revision', 'page'));
$this->addJoinConds(array('page' => array('INNER JOIN', array('page_id = rev_page'))));
if ($resultPageSet === null) {
$this->parseParameters($params);
$this->token = $params['token'];
$this->addFields(Revision::selectFields());
if ($this->token !== null || $pageCount > 0) {
$this->addFields(Revision::selectPageFields());
}
} else {
$this->limit = $this->getParameter('limit') ?: 10;
$this->addFields(array('rev_id', 'rev_page'));
}
if ($this->fld_tags) {
$this->addTables('tag_summary');
$this->addJoinConds(array('tag_summary' => array('LEFT JOIN', array('rev_id=ts_rev_id'))));
$this->addFields('ts_tags');
}
if (!is_null($params['tag'])) {
$this->addTables('change_tag');
$this->addJoinConds(array('change_tag' => array('INNER JOIN', array('rev_id=ct_rev_id'))));
$this->addWhereFld('ct_tag', $params['tag']);
}
if ($this->fetchContent) {
// For each page we will request, the user must have read rights for that page
$user = $this->getUser();
/** @var $title Title */
foreach ($pageSet->getGoodTitles() as $title) {
if (!$title->userCan('read', $user)) {
$this->dieUsage('The current user is not allowed to read ' . $title->getPrefixedText(), 'accessdenied');
}
}
$this->addTables('text');
$this->addJoinConds(array('text' => array('INNER JOIN', array('rev_text_id=old_id'))));
$this->addFields('old_id');
$this->addFields(Revision::selectTextFields());
}
// add user name, if needed
if ($this->fld_user) {
$this->addTables('user');
$this->addJoinConds(array('user' => Revision::userJoinCond()));
$this->addFields(Revision::selectUserFields());
}
if ($enumRevMode) {
// This is mostly to prevent parameter errors (and optimize SQL?)
if (!is_null($params['startid']) && !is_null($params['start'])) {
$this->dieUsage('start and startid cannot be used together', 'badparams');
}
if (!is_null($params['endid']) && !is_null($params['end'])) {
$this->dieUsage('end and endid cannot be used together', 'badparams');
}
if (!is_null($params['user']) && !is_null($params['excludeuser'])) {
$this->dieUsage('user and excludeuser cannot be used together', 'badparams');
}
// Continuing effectively uses startid. But we can't use rvstartid
// directly, because there is no way to tell the client to ''not''
// send rvstart if it sent it in the original query. So instead we
// send the continuation startid as rvcontinue, and ignore both
// rvstart and rvstartid when that is supplied.
if (!is_null($params['continue'])) {
$params['startid'] = $params['continue'];
$params['start'] = null;
}
// This code makes an assumption that sorting by rev_id and rev_timestamp produces
// the same result. This way users may request revisions starting at a given time,
// but to page through results use the rev_id returned after each page.
// Switching to rev_id removes the potential problem of having more than
//.........这里部分代码省略.........
示例5: loadFromDB
function loadFromDB($dbname, $page_id, $rev_id)
{
$db = wfGetDB(DB_SLAVE, 'stats', $dbname);
$fields = Revision::selectPageFields();
$fields = array_merge($fields, Revision::selectFields());
$fields[] = " date_format(rev_timestamp, '%Y-%m-%d %H:%i:%s') as ts ";
$oRow = $db->selectRow(array('revision', 'page'), $fields, array("rev_page = page_id", 'page_id' => $page_id, 'rev_id' => $rev_id), __METHOD__);
if (empty($oRow)) {
$fields = array('ar_namespace as page_namespace', 'ar_title as page_title', 'ar_comment as rev_comment', 'ar_user as rev_user', 'ar_user_text as rev_user_text', 'ar_timestamp as rev_timestamp', 'ar_minor_edit as rev_minor_edit', 'ar_rev_id as rev_id', 'ar_text_id as rev_text_id', 'ar_len as rev_len', 'ar_page_id as page_id', 'ar_page_id as rev_page', 'ar_deleted as rev_deleted', '0 as rev_parent_id', 'date_format(ar_timestamp, \'%Y-%m-%d %H:%i:%s\') as ts');
$conditions = array('ar_page_id' => $page_id, 'ar_rev_id' => $rev_id);
$oRow = $db->selectRow('archive', $fields, $conditions, __METHOD__);
}
return $oRow;
}
示例6: execute
public function execute()
{
$params = $this->extractRequestParams(false);
// 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 extremely
// difficult to manage continuations and require additional SQL indexes
$enumRevMode = !is_null($params['user']) || !is_null($params['excludeuser']) || !is_null($params['limit']) || !is_null($params['startid']) || !is_null($params['endid']) || $params['dir'] === 'newer' || !is_null($params['start']) || !is_null($params['end']);
$pageSet = $this->getPageSet();
$pageCount = $pageSet->getGoodTitleCount();
$revCount = $pageSet->getRevisionCount();
// Optimization -- nothing to do
if ($revCount === 0 && $pageCount === 0) {
return;
}
if ($revCount > 0 && $enumRevMode) {
$this->dieUsage('The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).', 'revids');
}
if ($pageCount > 1 && $enumRevMode) {
$this->dieUsage('titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.', 'multpages');
}
$this->addTables('revision');
$this->addFields(Revision::selectFields());
$this->addTables('page');
$this->addWhere('page_id = rev_page');
$prop = array_flip($params['prop']);
// Optional fields
$this->fld_ids = isset($prop['ids']);
// $this->addFieldsIf('rev_text_id', $this->fld_ids); // should this be exposed?
$this->fld_flags = isset($prop['flags']);
$this->fld_timestamp = isset($prop['timestamp']);
$this->fld_comment = isset($prop['comment']);
$this->fld_size = isset($prop['size']);
$this->fld_user = isset($prop['user']);
$this->token = $params['token'];
if (!is_null($this->token) || $pageCount > 0) {
$this->addFields(Revision::selectPageFields());
}
if (isset($prop['content'])) {
// For each page we will request, the user must have read rights for that page
foreach ($pageSet->getGoodTitles() as $title) {
if (!$title->userCanRead()) {
$this->dieUsage('The current user is not allowed to read ' . $title->getPrefixedText(), 'accessdenied');
}
}
$this->addTables('text');
$this->addWhere('rev_text_id=old_id');
$this->addFields('old_id');
$this->addFields(Revision::selectTextFields());
$this->fld_content = true;
$this->expandTemplates = $params['expandtemplates'];
$this->generateXML = $params['generatexml'];
if (isset($params['section'])) {
$this->section = $params['section'];
} else {
$this->section = false;
}
}
$userMax = $this->fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1;
$botMax = $this->fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2;
$limit = $params['limit'];
if ($limit == 'max') {
$limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
$this->getResult()->addValue('limits', $this->getModuleName(), $limit);
}
if ($enumRevMode) {
// This is mostly to prevent parameter errors (and optimize SQL?)
if (!is_null($params['startid']) && !is_null($params['start'])) {
$this->dieUsage('start and startid cannot be used together', 'badparams');
}
if (!is_null($params['endid']) && !is_null($params['end'])) {
$this->dieUsage('end and endid cannot be used together', 'badparams');
}
if (!is_null($params['user']) && !is_null($params['excludeuser'])) {
$this->dieUsage('user and excludeuser cannot be used together', 'badparams');
}
// This code makes an assumption that sorting by rev_id and rev_timestamp produces
// the same result. This way users may request revisions starting at a given time,
// but to page through results use the rev_id returned after each page.
// 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.
if (is_null($params['startid']) && is_null($params['endid'])) {
$this->addWhereRange('rev_timestamp', $params['dir'], $params['start'], $params['end']);
} else {
$this->addWhereRange('rev_id', $params['dir'], $params['startid'], $params['endid']);
}
// must manually initialize unset limit
if (is_null($limit)) {
$limit = 10;
}
$this->validateLimit('limit', $limit, 1, $userMax, $botMax);
// There is only one ID, use it
$this->addWhereFld('rev_page', current(array_keys($pageSet->getGoodTitles())));
if (!is_null($params['user'])) {
$this->addWhereFld('rev_user_text', $params['user']);
} elseif (!is_null($params['excludeuser'])) {
$this->addWhere('rev_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
}
} elseif ($revCount > 0) {
//.........这里部分代码省略.........
示例7: run
protected function run(ApiPageSet $resultPageSet = null)
{
$params = $this->extractRequestParams(false);
// 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 extremely
// difficult to manage continuations and require additional SQL indexes
$enumRevMode = $params['user'] !== null || $params['excludeuser'] !== null || $params['limit'] !== null || $params['startid'] !== null || $params['endid'] !== null || $params['dir'] === 'newer' || $params['start'] !== null || $params['end'] !== null;
$pageSet = $this->getPageSet();
$pageCount = $pageSet->getGoodTitleCount();
$revCount = $pageSet->getRevisionCount();
// Optimization -- nothing to do
if ($revCount === 0 && $pageCount === 0) {
// Nothing to do
return;
}
if ($revCount > 0 && count($pageSet->getLiveRevisionIDs()) === 0) {
// We're in revisions mode but all given revisions are deleted
return;
}
if ($revCount > 0 && $enumRevMode) {
$this->dieUsage('The revids= parameter may not be used with the list options ' . '(limit, startid, endid, dirNewer, start, end).', 'revids');
}
if ($pageCount > 1 && $enumRevMode) {
$this->dieUsage('titles, pageids or a generator was used to supply multiple pages, ' . 'but the limit, startid, endid, dirNewer, user, excludeuser, start ' . 'and end parameters may only be used on a single page.', 'multpages');
}
// In non-enum mode, rvlimit can't be directly used. Use the maximum
// allowed value.
if (!$enumRevMode) {
$this->setParsedLimit = false;
$params['limit'] = 'max';
}
$db = $this->getDB();
$this->addTables(['revision', 'page']);
$this->addJoinConds(['page' => ['INNER JOIN', ['page_id = rev_page']]]);
if ($resultPageSet === null) {
$this->parseParameters($params);
$this->token = $params['token'];
$this->addFields(Revision::selectFields());
if ($this->token !== null || $pageCount > 0) {
$this->addFields(Revision::selectPageFields());
}
} else {
$this->limit = $this->getParameter('limit') ?: 10;
$this->addFields(['rev_id', 'rev_timestamp', 'rev_page']);
}
if ($this->fld_tags) {
$this->addTables('tag_summary');
$this->addJoinConds(['tag_summary' => ['LEFT JOIN', ['rev_id=ts_rev_id']]]);
$this->addFields('ts_tags');
}
if ($params['tag'] !== null) {
$this->addTables('change_tag');
$this->addJoinConds(['change_tag' => ['INNER JOIN', ['rev_id=ct_rev_id']]]);
$this->addWhereFld('ct_tag', $params['tag']);
}
if ($this->fetchContent) {
// For each page we will request, the user must have read rights for that page
$user = $this->getUser();
/** @var $title Title */
foreach ($pageSet->getGoodTitles() as $title) {
if (!$title->userCan('read', $user)) {
$this->dieUsage('The current user is not allowed to read ' . $title->getPrefixedText(), 'accessdenied');
}
}
$this->addTables('text');
$this->addJoinConds(['text' => ['INNER JOIN', ['rev_text_id=old_id']]]);
$this->addFields('old_id');
$this->addFields(Revision::selectTextFields());
}
// add user name, if needed
if ($this->fld_user) {
$this->addTables('user');
$this->addJoinConds(['user' => Revision::userJoinCond()]);
$this->addFields(Revision::selectUserFields());
}
if ($enumRevMode) {
// Indexes targeted:
// page_timestamp if we don't have rvuser
// page_user_timestamp if we have a logged-in rvuser
// page_timestamp or usertext_timestamp if we have an IP rvuser
// This is mostly to prevent parameter errors (and optimize SQL?)
if ($params['startid'] !== null && $params['start'] !== null) {
$this->dieUsage('start and startid cannot be used together', 'badparams');
}
if ($params['endid'] !== null && $params['end'] !== null) {
$this->dieUsage('end and endid cannot be used together', 'badparams');
}
if ($params['user'] !== null && $params['excludeuser'] !== null) {
$this->dieUsage('user and excludeuser cannot be used together', 'badparams');
}
if ($params['continue'] !== null) {
$cont = explode('|', $params['continue']);
$this->dieContinueUsageIf(count($cont) != 2);
$op = $params['dir'] === 'newer' ? '>' : '<';
$continueTimestamp = $db->addQuotes($db->timestamp($cont[0]));
$continueId = (int) $cont[1];
$this->dieContinueUsageIf($continueId != $cont[1]);
$this->addWhere("rev_timestamp {$op} {$continueTimestamp} OR " . "(rev_timestamp = {$continueTimestamp} AND " . "rev_id {$op}= {$continueId})");
}
//.........这里部分代码省略.........
示例8: getRevisionFromPage
private function getRevisionFromPage()
{
wfProfileIn(__METHOD__);
$this->addTables('revision');
$this->addFields('page_id');
$this->addFields(Revision::selectPageFields());
$this->addFields(Revision::selectFields());
$this->addTables('page');
$this->addWhere('page_id = rev_page');
$this->addWhereFld('rev_id', $this->mRevId);
$this->addWhereFld('page_id', $this->mPageId);
$result = false;
$res = $this->select(__METHOD__);
$db = $this->getDB();
if ($oRow = $db->fetchObject($res)) {
if (is_object($oRow)) {
$result = $oRow;
}
}
$db->freeResult($res);
wfProfileOut(__METHOD__);
return $result;
}
示例9: getArticleText
/**
* Fetch an article from this or another local MediaWiki database.
* This is probably *very* fragile, and shouldn't be used perhaps.
*
* @param string $wiki
* @param string $article
* @return string
*/
function getArticleText($wiki, $article)
{
wfDebugLog('SpamBlacklist', "Fetching {$this->getBlacklistType()} blacklist from '{$article}' on '{$wiki}'...\n");
$title = Title::newFromText($article);
// Load all the relevant tables from the correct DB.
// This assumes that old_text is the actual text or
// that the external store system is at least unified.
$row = wfGetDB(DB_SLAVE, array(), $wiki)->selectRow(array('page', 'revision', 'text'), array_merge(Revision::selectFields(), Revision::selectPageFields(), Revision::selectTextFields()), array('page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey(), 'rev_id=page_latest', 'old_id=rev_text_id'), __METHOD__);
return $row ? Revision::newFromRow($row)->getText() : false;
}