private function badLockingMethodExplicit(IDatabase $db) { $lock = $db->getScopedLockAndFlush('meow', __METHOD__, 1); $db->begin(__METHOD__); throw new RunTimeException("Uh oh!"); }
/** * Acquire a lock for performing link table updates for a page on a DB * * @param IDatabase $dbw * @param integer $pageId * @param string $why One of (job, atomicity) * @return ScopedCallback * @throws RuntimeException * @since 1.27 */ public static function acquirePageLock(IDatabase $dbw, $pageId, $why = 'atomicity') { $key = "LinksUpdate:{$why}:pageid:{$pageId}"; $scopedLock = $dbw->getScopedLockAndFlush($key, __METHOD__, 15); if (!$scopedLock) { throw new RuntimeException("Could not acquire lock '{$key}'."); } return $scopedLock; }
/** * Acquire a lock for performing link table updates for a page on a DB * * @param IDatabase $dbw * @param integer $pageId * @return ScopedCallback|null Returns null on failure * @throws RuntimeException * @since 1.27 */ public static function acquirePageLock(IDatabase $dbw, $pageId) { $scopedLock = $dbw->getScopedLockAndFlush("LinksUpdate:pageid:{$pageId}", __METHOD__, 15); if (!$scopedLock) { throw new RuntimeException("Could not acquire lock on page #{$pageId}."); } return $scopedLock; }