当前位置: 首页>>代码示例>>PHP>>正文


PHP Revision::selectArchiveFields方法代码示例

本文整理汇总了PHP中Revision::selectArchiveFields方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::selectArchiveFields方法的具体用法?PHP Revision::selectArchiveFields怎么用?PHP Revision::selectArchiveFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Revision的用法示例。


在下文中一共展示了Revision::selectArchiveFields方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doQuery

 /**
  * @param IDatabase $db
  * @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'), Revision::selectArchiveFields(), 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));
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:31,代码来源:RevDelRevisionList.php

示例2: 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));
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:35,代码来源:RevDelRevisionList.php

示例3: doQuery

 /**
  * @param IDatabase $db
  * @return mixed
  */
 public function doQuery($db)
 {
     $timestamps = array();
     foreach ($this->ids as $id) {
         $timestamps[] = $db->timestamp($id);
     }
     return $db->select('archive', Revision::selectArchiveFields(), array('ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), 'ar_timestamp' => $timestamps), __METHOD__, array('ORDER BY' => 'ar_timestamp DESC'));
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:12,代码来源:RevDelArchiveList.php

示例4: doQuery

 /**
  * @param IDatabase $db
  * @return mixed
  */
 public function doQuery($db)
 {
     $timestamps = [];
     foreach ($this->ids as $id) {
         $timestamps[] = $db->timestamp($id);
     }
     $tables = ['archive'];
     $fields = Revision::selectArchiveFields();
     $conds = ['ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), 'ar_timestamp' => $timestamps];
     $join_conds = [];
     $options = ['ORDER BY' => 'ar_timestamp DESC'];
     ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $options, '');
     return $db->select($tables, $fields, $conds, __METHOD__, $options, $join_conds);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:18,代码来源:RevDelArchiveList.php

示例5: doDBUpdates

 public function doDBUpdates()
 {
     $db = $this->getDB(DB_MASTER);
     if (!$db->tableExists('revision')) {
         $this->error("revision table does not exist", true);
     } elseif (!$db->tableExists('archive')) {
         $this->error("archive table does not exist", true);
     } elseif (!$db->fieldExists('revision', 'rev_len', __METHOD__)) {
         $this->output("rev_len column does not exist\n\n", true);
         return false;
     }
     $this->output("Populating rev_len column\n");
     $rev = $this->doLenUpdates('revision', 'rev_id', 'rev', Revision::selectFields());
     $this->output("Populating ar_len column\n");
     $ar = $this->doLenUpdates('archive', 'ar_id', 'ar', Revision::selectArchiveFields());
     $this->output("rev_len and ar_len population complete [{$rev} revision rows, {$ar} archive rows].\n");
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:18,代码来源:populateRevisionLength.php

示例6: run

 /**
  * @param ApiPageSet $resultPageSet
  * @return void
  */
 protected function run(ApiPageSet $resultPageSet = null)
 {
     $user = $this->getUser();
     // Before doing anything at all, let's check permissions
     if (!$user->isAllowed('deletedhistory')) {
         $this->dieUsage('You don\'t have permission to view deleted revision information', 'permissiondenied');
     }
     $db = $this->getDB();
     $params = $this->extractRequestParams(false);
     $result = $this->getResult();
     // If the user wants no namespaces, they get no pages.
     if ($params['namespace'] === []) {
         if ($resultPageSet === null) {
             $result->addValue('query', $this->getModuleName(), []);
         }
         return;
     }
     // This module operates in two modes:
     // 'user': List deleted revs by a certain user
     // 'all': List all deleted revs in NS
     $mode = 'all';
     if (!is_null($params['user'])) {
         $mode = 'user';
     }
     if ($mode == 'user') {
         foreach (['from', 'to', 'prefix', 'excludeuser'] as $param) {
             if (!is_null($params[$param])) {
                 $p = $this->getModulePrefix();
                 $this->dieUsage("The '{$p}{$param}' parameter cannot be used with '{$p}user'", 'badparams');
             }
         }
     } else {
         foreach (['start', 'end'] as $param) {
             if (!is_null($params[$param])) {
                 $p = $this->getModulePrefix();
                 $this->dieUsage("The '{$p}{$param}' parameter may only be used with '{$p}user'", 'badparams');
             }
         }
     }
     // If we're generating titles only, we can use DISTINCT for a better
     // query. But we can't do that in 'user' mode (wrong index), and we can
     // only do it when sorting ASC (because MySQL apparently can't use an
     // index backwards for grouping even though it can for ORDER BY, WTF?)
     $dir = $params['dir'];
     $optimizeGenerateTitles = false;
     if ($mode === 'all' && $params['generatetitles'] && $resultPageSet !== null) {
         if ($dir === 'newer') {
             $optimizeGenerateTitles = true;
         } else {
             $p = $this->getModulePrefix();
             $this->setWarning("For better performance when generating titles, set {$p}dir=newer");
         }
     }
     $this->addTables('archive');
     if ($resultPageSet === null) {
         $this->parseParameters($params);
         $this->addFields(Revision::selectArchiveFields());
         $this->addFields(['ar_title', 'ar_namespace']);
     } else {
         $this->limit = $this->getParameter('limit') ?: 10;
         $this->addFields(['ar_title', 'ar_namespace']);
         if ($optimizeGenerateTitles) {
             $this->addOption('DISTINCT');
         } else {
             $this->addFields(['ar_timestamp', 'ar_rev_id', 'ar_id']);
         }
     }
     if ($this->fld_tags) {
         $this->addTables('tag_summary');
         $this->addJoinConds(['tag_summary' => ['LEFT JOIN', ['ar_rev_id=ts_rev_id']]]);
         $this->addFields('ts_tags');
     }
     if (!is_null($params['tag'])) {
         $this->addTables('change_tag');
         $this->addJoinConds(['change_tag' => ['INNER JOIN', ['ar_rev_id=ct_rev_id']]]);
         $this->addWhereFld('ct_tag', $params['tag']);
     }
     if ($this->fetchContent) {
         // Modern MediaWiki has the content for deleted revs in the 'text'
         // table using fields old_text and old_flags. But revisions deleted
         // pre-1.5 store the content in the 'archive' table directly using
         // fields ar_text and ar_flags, and no corresponding 'text' row. So
         // we have to LEFT JOIN and fetch all four fields.
         $this->addTables('text');
         $this->addJoinConds(['text' => ['LEFT JOIN', ['ar_text_id=old_id']]]);
         $this->addFields(['ar_text', 'ar_flags', 'old_text', 'old_flags']);
         // This also means stricter restrictions
         if (!$user->isAllowedAny('undelete', 'deletedtext')) {
             $this->dieUsage('You don\'t have permission to view deleted revision content', 'permissiondenied');
         }
     }
     $miser_ns = null;
     if ($mode == 'all') {
         if ($params['namespace'] !== null) {
             $namespaces = $params['namespace'];
         } else {
//.........这里部分代码省略.........
开发者ID:paladox,项目名称:mediawiki,代码行数:101,代码来源:ApiQueryAllDeletedRevisions.php

示例7: run

 protected function run(ApiPageSet $resultPageSet = null)
 {
     $user = $this->getUser();
     // Before doing anything at all, let's check permissions
     if (!$user->isAllowed('deletedhistory')) {
         $this->dieUsage('You don\'t have permission to view deleted revision information', 'permissiondenied');
     }
     $result = $this->getResult();
     $pageSet = $this->getPageSet();
     $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
     $pageCount = count($pageSet->getGoodAndMissingTitles());
     $revCount = $pageSet->getRevisionCount();
     if ($revCount === 0 && $pageCount === 0) {
         // Nothing to do
         return;
     }
     if ($revCount !== 0 && count($pageSet->getDeletedRevisionIDs()) === 0) {
         // Nothing to do, revisions were supplied but none are deleted
         return;
     }
     $params = $this->extractRequestParams(false);
     $db = $this->getDB();
     if (!is_null($params['user']) && !is_null($params['excludeuser'])) {
         $this->dieUsage('user and excludeuser cannot be used together', 'badparams');
     }
     $this->addTables('archive');
     if ($resultPageSet === null) {
         $this->parseParameters($params);
         $this->addFields(Revision::selectArchiveFields());
         $this->addFields(array('ar_title', 'ar_namespace'));
     } else {
         $this->limit = $this->getParameter('limit') ?: 10;
         $this->addFields(array('ar_title', 'ar_namespace', 'ar_timestamp', 'ar_rev_id', 'ar_id'));
     }
     if ($this->fld_tags) {
         $this->addTables('tag_summary');
         $this->addJoinConds(array('tag_summary' => array('LEFT JOIN', array('ar_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('ar_rev_id=ct_rev_id'))));
         $this->addWhereFld('ct_tag', $params['tag']);
     }
     if ($this->fetchContent) {
         // Modern MediaWiki has the content for deleted revs in the 'text'
         // table using fields old_text and old_flags. But revisions deleted
         // pre-1.5 store the content in the 'archive' table directly using
         // fields ar_text and ar_flags, and no corresponding 'text' row. So
         // we have to LEFT JOIN and fetch all four fields.
         $this->addTables('text');
         $this->addJoinConds(array('text' => array('LEFT JOIN', array('ar_text_id=old_id'))));
         $this->addFields(array('ar_text', 'ar_flags', 'old_text', 'old_flags'));
         // This also means stricter restrictions
         if (!$user->isAllowedAny('undelete', 'deletedtext')) {
             $this->dieUsage('You don\'t have permission to view deleted revision content', 'permissiondenied');
         }
     }
     $dir = $params['dir'];
     if ($revCount !== 0) {
         $this->addWhere(array('ar_rev_id' => array_keys($pageSet->getDeletedRevisionIDs())));
     } else {
         // We need a custom WHERE clause that matches all titles.
         $lb = new LinkBatch($pageSet->getGoodAndMissingTitles());
         $where = $lb->constructSet('ar', $db);
         $this->addWhere($where);
     }
     if (!is_null($params['user'])) {
         $this->addWhereFld('ar_user_text', $params['user']);
     } elseif (!is_null($params['excludeuser'])) {
         $this->addWhere('ar_user_text != ' . $db->addQuotes($params['excludeuser']));
     }
     if (!is_null($params['user']) || !is_null($params['excludeuser'])) {
         // Paranoia: avoid brute force searches (bug 17342)
         // (shouldn't be able to get here without 'deletedhistory', but
         // check it again just in case)
         if (!$user->isAllowed('deletedhistory')) {
             $bitmask = Revision::DELETED_USER;
         } elseif (!$user->isAllowedAny('suppressrevision', 'viewsuppressed')) {
             $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
         } else {
             $bitmask = 0;
         }
         if ($bitmask) {
             $this->addWhere($db->bitAnd('ar_deleted', $bitmask) . " != {$bitmask}");
         }
     }
     if (!is_null($params['continue'])) {
         $cont = explode('|', $params['continue']);
         $op = $dir == 'newer' ? '>' : '<';
         if ($revCount !== 0) {
             $this->dieContinueUsageIf(count($cont) != 2);
             $rev = intval($cont[0]);
             $this->dieContinueUsageIf(strval($rev) !== $cont[0]);
             $ar_id = (int) $cont[1];
             $this->dieContinueUsageIf(strval($ar_id) !== $cont[1]);
             $this->addWhere("ar_rev_id {$op} {$rev} OR " . "(ar_rev_id = {$rev} AND " . "ar_id {$op}= {$ar_id})");
         } else {
             $this->dieContinueUsageIf(count($cont) != 4);
             $ns = intval($cont[0]);
//.........这里部分代码省略.........
开发者ID:D66Ha,项目名称:mediawiki,代码行数:101,代码来源:ApiQueryDeletedRevisions.php


注:本文中的Revision::selectArchiveFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。