本文整理汇总了PHP中Revision::userJoinCond方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::userJoinCond方法的具体用法?PHP Revision::userJoinCond怎么用?PHP Revision::userJoinCond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::userJoinCond方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$ids = array_map('intval', $this->ids);
$queryInfo = array('tables' => array('revision', 'user'), 'fields' => array_merge(Revision::selectFields(), Revision::selectUserFields()), 'conds' => array('rev_page' => $this->title->getArticleID(), 'rev_id' => $ids), 'options' => array('ORDER BY' => 'rev_id DESC'), 'join_conds' => array('page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()));
ChangeTags::modifyDisplayQuery($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], $queryInfo['join_conds'], $queryInfo['options'], '');
return $db->select($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], __METHOD__, $queryInfo['options'], $queryInfo['join_conds']);
}
示例2: doQuery
/**
* @param $db DatabaseBase
* @return mixed
*/
public function doQuery($db)
{
$ids = array_map('intval', $this->ids);
$live = $db->select(array('revision', 'page', 'user'), array_merge(Revision::selectFields(), Revision::selectUserFields()), array('rev_page' => $this->title->getArticleID(), 'rev_id' => $ids), __METHOD__, array('ORDER BY' => 'rev_id DESC'), array('page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()));
if ($live->numRows() >= count($ids)) {
// All requested revisions are live, keeps things simple!
return $live;
}
// Check if any requested revisions are available fully deleted.
$archived = $db->select(array('archive'), '*', array('ar_rev_id' => $ids), __METHOD__, array('ORDER BY' => 'ar_rev_id DESC'));
if ($archived->numRows() == 0) {
return $live;
} elseif ($live->numRows() == 0) {
return $archived;
} else {
// Combine the two! Whee
$rows = array();
foreach ($live as $row) {
$rows[$row->rev_id] = $row;
}
foreach ($archived as $row) {
$rows[$row->ar_rev_id] = $row;
}
krsort($rows);
return new FakeResultWrapper(array_values($rows));
}
}
示例3: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$ids = array_map('intval', $this->ids);
$queryInfo = ['tables' => ['revision', 'user'], 'fields' => array_merge(Revision::selectFields(), Revision::selectUserFields()), 'conds' => ['rev_page' => $this->title->getArticleID(), 'rev_id' => $ids], 'options' => ['ORDER BY' => 'rev_id DESC'], 'join_conds' => ['page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()]];
ChangeTags::modifyDisplayQuery($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], $queryInfo['join_conds'], $queryInfo['options'], '');
$live = $db->select($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], __METHOD__, $queryInfo['options'], $queryInfo['join_conds']);
if ($live->numRows() >= count($ids)) {
// All requested revisions are live, keeps things simple!
return $live;
}
$archiveQueryInfo = ['tables' => ['archive'], 'fields' => Revision::selectArchiveFields(), 'conds' => ['ar_rev_id' => $ids], 'options' => ['ORDER BY' => 'ar_rev_id DESC'], 'join_conds' => []];
ChangeTags::modifyDisplayQuery($archiveQueryInfo['tables'], $archiveQueryInfo['fields'], $archiveQueryInfo['conds'], $archiveQueryInfo['join_conds'], $archiveQueryInfo['options'], '');
// Check if any requested revisions are available fully deleted.
$archived = $db->select($archiveQueryInfo['tables'], $archiveQueryInfo['fields'], $archiveQueryInfo['conds'], __METHOD__, $archiveQueryInfo['options'], $archiveQueryInfo['join_conds']);
if ($archived->numRows() == 0) {
return $live;
} elseif ($live->numRows() == 0) {
return $archived;
} else {
// Combine the two! Whee
$rows = [];
foreach ($live as $row) {
$rows[$row->rev_id] = $row;
}
foreach ($archived as $row) {
$rows[$row->ar_rev_id] = $row;
}
krsort($rows);
return new FakeResultWrapper(array_values($rows));
}
}
示例4: getQueryInfo
function getQueryInfo()
{
$conds = $this->mConds;
$conds['rev_page'] = $this->articleID;
$conds[] = "rev_timestamp < " . $this->mDb->addQuotes($this->maxTimestamp);
return ['tables' => ['revision', 'page', 'user'], 'fields' => array_merge(Revision::selectFields(), Revision::selectUserFields()), 'conds' => $conds, 'join_conds' => ['page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()]];
}
示例5: 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
//.........这里部分代码省略.........
示例6: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$conds = ['rev_page' => $this->title->getArticleID()];
if ($this->ids !== null) {
$conds['rev_id'] = array_map('intval', $this->ids);
}
return $db->select(['revision', 'page', 'user'], array_merge(Revision::selectFields(), Revision::selectUserFields()), $conds, __METHOD__, ['ORDER BY' => 'rev_id DESC'], ['page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()]);
}
示例7: getQueryInfo
function getQueryInfo()
{
$queryInfo = array('tables' => array('revision', 'user'), 'fields' => array_merge(Revision::selectFields(), Revision::selectUserFields()), 'conds' => array_merge(array('rev_page' => $this->getWikiPage()->getId()), $this->conds), 'options' => array('USE INDEX' => array('revision' => 'page_timestamp')), 'join_conds' => array('user' => Revision::userJoinCond()));
ChangeTags::modifyDisplayQuery($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], $queryInfo['join_conds'], $queryInfo['options'], $this->tagFilter);
wfRunHooks('PageHistoryPager::getQueryInfo', array(&$this, &$queryInfo));
return $queryInfo;
}
示例8: getQueryInfo
function getQueryInfo()
{
list($tables, $index, $userCond, $join_cond) = $this->getUserCond();
$user = $this->getUser();
$conds = array_merge($userCond, $this->getNamespaceCond());
// Paranoia: avoid brute force searches (bug 17342)
if (!$user->isAllowed('deletedhistory')) {
$conds[] = $this->mDb->bitAnd('rev_deleted', Revision::DELETED_USER) . ' = 0';
} elseif (!$user->isAllowed('suppressrevision')) {
$conds[] = $this->mDb->bitAnd('rev_deleted', Revision::SUPPRESSED_USER) . ' != ' . Revision::SUPPRESSED_USER;
}
# Don't include orphaned revisions
$join_cond['page'] = Revision::pageJoinCond();
# Get the current user name for accounts
$join_cond['user'] = Revision::userJoinCond();
$queryInfo = array('tables' => $tables, 'fields' => array_merge(Revision::selectFields(), Revision::selectUserFields(), array('page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect', 'page_len')), 'conds' => $conds, 'options' => array('USE INDEX' => array('revision' => $index)), 'join_conds' => $join_cond);
ChangeTags::modifyDisplayQuery($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], $queryInfo['join_conds'], $queryInfo['options'], $this->tagFilter);
wfRunHooks('ContribsPager::getQueryInfo', array(&$this, &$queryInfo));
return $queryInfo;
}
示例9: execute
//.........这里部分代码省略.........
}
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'];
$this->generateXML = $params['generatexml'];
$this->parseContent = $params['parse'];
if ($this->parseContent) {
// Must manually initialize unset limit
if (is_null($limit)) {
$limit = 1;
}
// We are only going to parse 1 revision per request
$this->validateLimit('limit', $limit, 1, 1, 1);
}
if (isset($params['section'])) {
$this->section = $params['section'];
} else {
$this->section = false;
}
}
// add user name, if needed
if ($this->fld_user) {
$this->addTables('user');
$this->addJoinConds(array('user' => Revision::userJoinCond()));
$this->addFields(Revision::selectUserFields());
}
// Bug 24166 - API error when using rvprop=tags
$this->addTables('revision');
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'];
unset($params['start']);
}
// 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->addTimestampWhereRange('rev_timestamp', $params['dir'], $params['start'], $params['end']);
示例10: getQueryInfo
function getQueryInfo() {
$conds = $this->mConds;
$conds['rev_page'] = $this->articleID;
$conds[] = "rev_timestamp < {$this->maxTimestamp}";
return array(
'tables' => array( 'revision', 'page', 'user' ),
'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
'conds' => $conds,
'join_conds' => array(
'page' => Revision::pageJoinCond(),
'user' => Revision::userJoinCond() )
);
}
示例11: 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})");
}
//.........这里部分代码省略.........