Exemple #1
0
 /**
  * If the given revision is newer than the currently set page_latest,
  * update the page record. Otherwise, do nothing.
  *
  * @deprecated since 1.24, use updateRevisionOn instead
  *
  * @param IDatabase $dbw
  * @param Revision $revision
  * @return bool
  */
 public function updateIfNewerOn($dbw, $revision)
 {
     $row = $dbw->selectRow(['revision', 'page'], ['rev_id', 'rev_timestamp', 'page_is_redirect'], ['page_id' => $this->getId(), 'page_latest=rev_id'], __METHOD__);
     if ($row) {
         if (wfTimestamp(TS_MW, $row->rev_timestamp) >= $revision->getTimestamp()) {
             return false;
         }
         $prev = $row->rev_id;
         $lastRevIsRedirect = (bool) $row->page_is_redirect;
     } else {
         // No or missing previous revision; mark the page as new
         $prev = 0;
         $lastRevIsRedirect = null;
     }
     $ret = $this->updateRevisionOn($dbw, $revision, $prev, $lastRevIsRedirect);
     return $ret;
 }
Exemple #2
0
 /**
  * @param IDatabase $dbr
  * @param string $fname
  * @return array|bool
  */
 private function loadFieldsWithTimestamp($dbr, $fname)
 {
     $fieldMap = false;
     $row = $dbr->selectRow('image', $this->getLazyCacheFields('img_'), array('img_name' => $this->getName(), 'img_timestamp' => $this->getTimestamp()), $fname);
     if ($row) {
         $fieldMap = $this->unprefixRow($row, 'img_');
     } else {
         # File may have been uploaded over in the meantime; check the old versions
         $row = $dbr->selectRow('oldimage', $this->getLazyCacheFields('oi_'), array('oi_name' => $this->getName(), 'oi_timestamp' => $this->getTimestamp()), $fname);
         if ($row) {
             $fieldMap = $this->unprefixRow($row, 'oi_');
         }
     }
     return $fieldMap;
 }
Exemple #3
0
 /**
  * @param IDatabase $db
  * @return bool|stdClass
  */
 static function doLoad($db)
 {
     return $db->selectRow('site_stats', ['ss_row_id', 'ss_total_edits', 'ss_good_articles', 'ss_total_pages', 'ss_users', 'ss_active_users', 'ss_images'], [], __METHOD__);
 }
Exemple #4
0
 /**
  * Get count of revisions per page...not very efficient
  *
  * @param IDatabase $db
  * @param int $id Page id
  * @return int
  */
 static function countByPageId($db, $id)
 {
     $row = $db->selectRow('revision', array('revCount' => 'COUNT(*)'), array('rev_page' => $id), __METHOD__);
     if ($row) {
         return $row->revCount;
     }
     return 0;
 }
Exemple #5
0
 private function fetchPageRow(IDatabase $db, LinkTarget $nt)
 {
     $fields = self::getSelectFields();
     if ($this->isCacheable($nt)) {
         $fields[] = 'page_touched';
     }
     return $db->selectRow('page', $fields, ['page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey()], __METHOD__);
 }