/** * We'll be querying the workflow table instead of the revisions table. * Because it's possible to request only a couple of revisions (in between * certain ids), we'll need to override the parent buildQueryConditions * method to also work on the workflow table. * A topic workflow is updated with a workflow_last_update_timestamp for * every change made in the topic. Our UUIDs are sequential & time-based, * so we can just query for workflows with a timestamp higher than the * timestamp derived from the starting UUID and lower than the end UUID. * * {@inheritDoc} */ public function buildQueryConditions(UUID $fromId = null, UUID $toId = null, $namespace = null) { $dbr = $this->dbFactory->getDB(DB_SLAVE); $conditions = array(); // only find entries in a given range if ($fromId !== null) { $conditions[] = 'workflow_last_update_timestamp >= ' . $dbr->addQuotes($fromId->getTimestamp()); } if ($toId !== null) { $conditions[] = 'workflow_last_update_timestamp <= ' . $dbr->addQuotes($toId->getTimestamp()); } // find only within requested wiki/namespace $conditions['workflow_wiki'] = wfWikiId(); if ($namespace !== null) { $conditions['workflow_namespace'] = $namespace; } return $conditions; }
/** * Finds the RecentChange object associated with this flow revision. * * @return null|RecentChange */ public function getRecentChange() { $timestamp = $this->revId->getTimestamp(); if (!RecentChange::isInRCLifespan($timestamp)) { // Too old to be in RC, don't even bother checking return null; } $workflow = $this->getCollection()->getWorkflow(); if ($this->changeType === 'new-post') { $title = $workflow->getOwnerTitle(); } else { $title = $workflow->getArticleTitle(); } $namespace = $title->getNamespace(); $conditions = array('rc_title' => $title->getDBkey(), 'rc_timestamp' => $timestamp, 'rc_namespace' => $namespace); $options = array('USE INDEX' => 'rc_timestamp'); $dbr = wfGetDB(DB_SLAVE); $rows = $dbr->select('recentchanges', RecentChange::selectFields(), $conditions, __METHOD__, $options); if ($rows === false) { return null; } if ($rows->numRows() === 1) { return RecentChange::newFromRow($rows->fetchObject()); } // it is possible that more than 1 changes on the same page have the same timestamp // the revision id is hidden in rc_params['flow-workflow-change']['revision'] $revId = $this->revId->getAlphadecimal(); while ($row = $rows->next()) { $rc = RecentChange::newFromRow($row); $params = $rc->parseParams(); if ($params && $params['flow-workflow-change']['revision'] === $revId) { return $rc; } } return null; }
public function updateLastModified(UUID $latestRevisionId) { $this->lastModified = $latestRevisionId->getTimestamp(); }
/** * Notify the state about a modification action at a given time. * * @param UUID $uuid UUID of the modification revision. */ public function recordModificationTime(UUID $uuid) { $timestamp = $uuid->getTimestamp(); $timestamp = wfTimestamp(TS_MW, $timestamp); if ($timestamp > $this->lastModified) { $this->lastModified = $timestamp; } }