X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fdeferred%2FLinksUpdate.php;h=577a272000b5b9abd909aa37668e9cfeeb69bbe2;hb=3d98b80a3901a4f843af38066f4f1538ec635976;hp=ae3c66008c26110e70d85c45d0a332a3aac8e7c9;hpb=fe25fde55bc9e58741965ad0f2275a7ba2ac77fa;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/deferred/LinksUpdate.php b/includes/deferred/LinksUpdate.php index ae3c66008c..577a272000 100644 --- a/includes/deferred/LinksUpdate.php +++ b/includes/deferred/LinksUpdate.php @@ -21,6 +21,7 @@ */ use Wikimedia\Rdbms\IDatabase; +use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use Wikimedia\ScopedCallback; @@ -163,6 +164,9 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { // Make sure all links update threads see the changes of each other. // This handles the case when updates have to batched into several COMMITs. $scopedLock = self::acquirePageLock( $this->getDB(), $this->mId ); + if ( !$scopedLock ) { + throw new RuntimeException( "Could not acquire lock for page ID '{$this->mId}'." ); + } } // Avoid PHP 7.1 warning from passing $this by reference @@ -190,15 +194,19 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { * @param IDatabase $dbw * @param int $pageId * @param string $why One of (job, atomicity) - * @return ScopedCallback - * @throws RuntimeException + * @return ScopedCallback|null * @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'." ); + $logger = LoggerFactory::getInstance( 'SecondaryDataUpdate' ); + $logger->info( "Could not acquire lock '{key}' for page ID '{page_id}'.", [ + 'key' => $key, + 'page_id' => $pageId, + ] ); + return null; } return $scopedLock; @@ -397,7 +405,7 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { /** * @param array $images */ - private function invalidateImageDescriptions( $images ) { + private function invalidateImageDescriptions( array $images ) { PurgeJobUtils::invalidatePages( $this->getDB(), NS_FILE, array_keys( $images ) ); } @@ -584,10 +592,11 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { global $wgCategoryCollation; $diffs = array_diff_assoc( $this->mCategories, $existing ); $arr = []; + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); + $collation = Collation::singleton(); foreach ( $diffs as $name => $prefix ) { $nt = Title::makeTitleSafe( NS_CATEGORY, $name ); - MediaWikiServices::getInstance()->getContentLanguage()-> - findVariantLink( $name, $nt, true ); + $contLang->findVariantLink( $name, $nt, true ); $type = MWNamespace::getCategoryLinkType( $this->mTitle->getNamespace() ); @@ -595,8 +604,7 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { # things are forced to sort as '*' or something, they'll # sort properly in the category rather than in page_id # order or such. - $sortkey = Collation::singleton()->getSortKey( - $this->mTitle->getCategorySortkey( $prefix ) ); + $sortkey = $collation->getSortKey( $this->mTitle->getCategorySortkey( $prefix ) ); $arr[] = [ 'cl_from' => $this->mId,