*
* @param IDatabase $dbw
* @param integer $pageId
- * @return ScopedCallback|null Returns null on failure
+ * @param string $why One of (job, atomicity)
+ * @return ScopedCallback
* @throws RuntimeException
* @since 1.27
*/
- public static function acquirePageLock( IDatabase $dbw, $pageId ) {
- $scopedLock = $dbw->getScopedLockAndFlush(
- "LinksUpdate:pageid:$pageId",
- __METHOD__,
- 15
- );
+ 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 on page #$pageId." );
+ throw new RuntimeException( "Could not acquire lock '$key'." );
}
return $scopedLock;
* @param array $cats
*/
function invalidateCategories( $cats ) {
- $this->invalidatePages( NS_CATEGORY, array_keys( $cats ) );
+ PurgeJobUtils::invalidatePages( $this->mDb, NS_CATEGORY, array_keys( $cats ) );
}
/**
* @param array $images
*/
function invalidateImageDescriptions( $images ) {
- $this->invalidatePages( NS_FILE, array_keys( $images ) );
+ PurgeJobUtils::invalidatePages( $this->mDb, NS_FILE, array_keys( $images ) );
}
/**
*/
private function incrTableUpdate( $table, $prefix, $deletions, $insertions ) {
$bSize = RequestContext::getMain()->getConfig()->get( 'UpdateRowsPerQuery' );
+ $factory = wfGetLBFactory();
if ( $table === 'page_props' ) {
$fromField = 'pp_page';
foreach ( $deleteWheres as $deleteWhere ) {
$this->mDb->delete( $table, $deleteWhere, __METHOD__ );
- $this->mDb->commit( __METHOD__, 'flush' );
- wfGetLBFactory()->waitForReplication( [ 'wiki' => $this->mDb->getWikiID() ] );
+ $factory->commitAndWaitForReplication(
+ __METHOD__, $this->ticket, [ 'wiki' => $this->mDb->getWikiID() ]
+ );
}
$insertBatches = array_chunk( $insertions, $bSize );
foreach ( $insertBatches as $insertBatch ) {
$this->mDb->insert( $table, $insertBatch, __METHOD__, 'IGNORE' );
- $this->mDb->commit( __METHOD__, 'flush' );
- wfGetLBFactory()->waitForReplication( [ 'wiki' => $this->mDb->getWikiID() ] );
+ $factory->commitAndWaitForReplication(
+ __METHOD__, $this->ticket, [ 'wiki' => $this->mDb->getWikiID() ]
+ );
}
if ( count( $insertions ) ) {