/** * Pop a job of a certain type. This tries less hard than pop() to * actually find a job; it may be adversely affected by concurrent job * runners. */ static function pop_type($type) { wfProfilein(__METHOD__); $dbw = wfGetDB(DB_MASTER); $row = $dbw->selectRow('job', '*', array('job_cmd' => $type), __METHOD__, array('LIMIT' => 1)); if ($row === false) { wfProfileOut(__METHOD__); return false; } /* Ensure we "own" this row */ try { $dbw->delete('job', array('job_id' => $row->job_id), __METHOD__); $affected = $dbw->affectedRows(); if ($affected == 0) { wfProfileOut(__METHOD__); return false; } $namespace = $row->job_namespace; $dbkey = $row->job_title; $title = Title::makeTitleSafe($namespace, $dbkey); $job = Job::factory($row->job_cmd, $title, Job::extractBlob($row->job_params), $row->job_id); $dbw->delete('job', $job->insertFields(), __METHOD__); $dbw->immediateCommit(); } catch (Exception $ee) { } wfProfileOut(__METHOD__); return $job; }
/** * Pop a job of a certain type. This tries less hard than pop() to * actually find a job; it may be adversely affected by concurrent job * runners. * * @param $type string * * @return Job */ static function pop_type($type) { wfProfilein(__METHOD__); $dbw = wfGetDB(DB_MASTER); $dbw->begin(__METHOD__); $row = $dbw->selectRow('job', '*', array('job_cmd' => $type), __METHOD__, array('LIMIT' => 1, 'FOR UPDATE')); if ($row === false) { $dbw->commit(__METHOD__); wfProfileOut(__METHOD__); return false; } /* Ensure we "own" this row */ $dbw->delete('job', array('job_id' => $row->job_id), __METHOD__); $affected = $dbw->affectedRows(); $dbw->commit(__METHOD__); if ($affected == 0) { wfProfileOut(__METHOD__); return false; } wfIncrStats('job-pop'); $namespace = $row->job_namespace; $dbkey = $row->job_title; $title = Title::makeTitleSafe($namespace, $dbkey); $job = Job::factory($row->job_cmd, $title, Job::extractBlob($row->job_params), $row->job_id); $job->removeDuplicates(); wfProfileOut(__METHOD__); return $job; }
protected static function getBlockFromCache(User $user, $isCurrentUser) { global $wgMemc; wfProfilein(__METHOD__); $cacheKey = self::getCacheKey($user); $cachedState = $wgMemc->get($cacheKey); if (!empty($cachedState) && $cachedState['timestamp'] > (int) Phalanx::getLastUpdate()) { if (!$cachedState['return'] && $isCurrentUser) { self::setUserData($user, $cachedState['block'], '', $user->isAnon()); } //added to make User::isBlockedGlobally() work for this instance of User class $user->mBlockedGlobally = !$cachedState['return']; wfProfileOut(__METHOD__); return $cachedState['return']; } wfProfileOut(__METHOD__); return null; }
protected static function getBlockFromCache(User $user, $isCurrentUser) { global $wgMemc; wfProfilein(__METHOD__); $cacheKey = self::getCacheKey($user); $cachedState = $wgMemc->get($cacheKey); if (!empty($cachedState) && $cachedState['timestamp'] > (int) PhalanxFallback::getLastUpdate()) { if (!$cachedState['return'] && $isCurrentUser) { self::setUserData($user, $cachedState['block'], '', $user->isAnon()); } wfProfileOut(__METHOD__); return $cachedState; } wfProfileOut(__METHOD__); return null; }