static function onArticleUndelete(&$udTitle, $created, $comment = '') { if (empty(self::$pageids_to_revive)) { return true; } foreach (self::$pageids_to_revive as $pageid => $title) { if ($pageid == 0) { continue; } // Try to get comment for old versions where it isn't passed, hacky :( if (!$comment) { global $wgRequest; $comment = $wgRequest->getText('wpComment'); } // TX has not been committed yet, so we must select from the master $dbw = wfGetDB(DB_MASTER); $res = $dbw->select('thread', '*', array('thread_root' => $pageid), __METHOD__); $threads = Threads::loadFromResult($res, $dbw); if (count($threads)) { $thread = array_pop($threads); $thread->setRoot(new Article($title)); $thread->undelete($comment); } else { wfDebug(__METHOD__ . ":No thread found with root set to {$pageid} (??)\n"); } } // Synchronise the first 500 threads, in reverse order by thread id. If // there are more threads to synchronise, the job queue will take over. Threads::synchroniseArticleData(new Article($udTitle), 500, 'cascade'); return true; }
static function where($where, $options = array(), $bulkLoad = true) { $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('thread', '*', $where, __METHOD__, $options); $threads = Threads::loadFromResult($res, $dbr, $bulkLoad); foreach ($threads as $thread) { if ($thread->root()) { self::$cache_by_root[$thread->root()->getId()] = $thread; } self::$cache_by_id[$thread->id()] = $thread; } return $threads; }
static function watchedThreadsForUser($user) { $talkPage = new Article($user->getUserPage()->getTalkPage()); $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select(array('thread', 'user_message_state'), '*', array('ums_read_timestamp' => null, 'ums_user' => $user->getId(), 'not (' . Threads::articleClause($talkPage) . ')'), __METHOD__, array(), array('user_message_state' => array('INNER JOIN', 'ums_thread=thread_id'))); return Threads::loadFromResult($res, $dbr); }
if (!$db->fieldExists('thread', $field, 'lqt-update-script')) { $db->sourceFile(dirname(__FILE__) . '/schema-changes/' . $patch); } } foreach ($threadIndexUpdates as $index => $patch) { if (!$db->indexExists('thread', $index, 'lqt-update-script')) { $db->sourceFile(dirname(__FILE__) . '/schema-changes/' . $patch); } } foreach ($newTableUpdates as $table => $patch) { if (!$db->tableExists($table, 'lqt-update-script')) { $db->sourceFile(dirname(__FILE__) . '/schema-changes/' . $patch); } } // Batch lazy updates $upTo = $lastUpTo = 0; do { $lastUpTo = $upTo; $db->begin(); // Read 500 rows $res = $db->select('thread', '*', array('thread_id>' . $db->addQuotes($upTo)), 'lqt-update-script', array('LIMIT' => 500, 'FOR UPDATE', 'ORDER BY' => 'thread_id asc')); $threads = Threads::loadFromResult($res, $db); foreach ($threads as $thread) { $thread->doLazyUpdates(); $thread->updateHistory(); if ($thread->id() > $upTo) { $upTo = $thread->id(); } } $db->commit(); } while ($lastUpTo != $upTo);