public function refreshBatch(DatabaseBase $dbr, UUID $continue, $countableActions, UUID $stop) { $rows = $dbr->select('flow_revision', array('rev_id', 'rev_user_id'), array('rev_id > ' . $dbr->addQuotes($continue->getBinary()), 'rev_id <= ' . $dbr->addQuotes($stop->getBinary()), 'rev_user_id > 0', 'rev_user_wiki' => wfWikiID(), 'rev_change_type' => $countableActions), __METHOD__, array('ORDER BY' => 'rev_id ASC', 'LIMIT' => $this->mBatchSize)); // end of data if (!$rows || $rows->numRows() === 0) { return false; } foreach ($rows as $row) { // User::incEditCount only allows for edit count to be increased 1 // at a time. It'd be better to immediately be able to increase the // edit count by the exact number it should be increased with, but // I'd rather re-use existing code, especially in a run-once script, // where performance is not the most important thing ;) $user = User::newFromId($row->rev_user_id); $user->incEditCount(); // save updates so we can print them when the script is done running if (!isset($this->updates[$user->getId()])) { $this->updates[$user->getId()] = 0; } $this->updates[$user->getId()]++; // set value for next batch to continue at $continue = $row->rev_id; } return UUID::create($continue); }
/** * @param UUID|null $fromId * @param UUID|null $toId * @param int|null $namespace * @return array */ 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[] = 'rev_id >= ' . $dbr->addQuotes($fromId->getBinary()); } if ($toId !== null) { $conditions[] = 'rev_id <= ' . $dbr->addQuotes($toId->getBinary()); } // find only within requested wiki/namespace $conditions['workflow_wiki'] = wfWikiId(); if ($namespace !== null) { $conditions['workflow_namespace'] = $namespace; } return $conditions; }