示例#1
0
 /**
  * Load either the current, or a specified, revision
  * that's attached to a given title. If not attached
  * to that title, will return null.
  *
  * @param Title $title
  * @param int $id
  * @return Revision
  * @access public
  * @static
  */
 static function newFromTitle(&$title, $id = 0)
 {
     if ($id) {
         $matchId = intval($id);
     } else {
         $matchId = 'page_latest';
     }
     return Revision::newFromConds(array("rev_id={$matchId}", 'page_id=rev_page', 'page_namespace' => $title->getNamespace(), 'page_title' => $title->getDbkey()));
 }
示例#2
0
 /**
  * Load either the current, or a specified, revision
  * that's attached to a given title. If not attached
  * to that title, will return null.
  *
  * @param Title $title
  * @param int $id
  * @return Revision
  */
 public static function newFromTitle($title, $id = 0)
 {
     $conds = array('page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey());
     if ($id) {
         // Use the specified ID
         $conds['rev_id'] = $id;
     } elseif (wfGetLB()->getServerCount() > 1) {
         // Get the latest revision ID from the master
         $dbw = wfGetDB(DB_MASTER);
         $latest = $dbw->selectField('page', 'page_latest', $conds, __METHOD__);
         $conds['rev_id'] = $latest;
     } else {
         // Use a join to get the latest revision
         $conds[] = 'rev_id=page_latest';
     }
     $conds[] = 'page_id=rev_page';
     return Revision::newFromConds($conds);
 }
示例#3
0
 /**
  * Load either the current, or a specified, revision
  * that's attached to a given page ID.
  * Returns null if no such revision can be found.
  *
  * @param $revId Integer
  * @param $pageId Integer (optional)
  * @return Revision or null
  */
 public static function newFromPageId($pageId, $revId = 0)
 {
     $conds = array('page_id' => $pageId);
     if ($revId) {
         $conds['rev_id'] = $revId;
     } elseif (wfGetLB()->getServerCount() > 1) {
         // Get the latest revision ID from the master
         $dbw = wfGetDB(DB_MASTER);
         $latest = $dbw->selectField('page', 'page_latest', $conds, __METHOD__);
         if ($latest === false) {
             return null;
             // page does not exist
         }
         $conds['rev_id'] = $latest;
     } else {
         $conds[] = 'rev_id = page_latest';
     }
     return Revision::newFromConds($conds);
 }