dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Handle missing namespace prefix in XML dumps more gracefully"
[lhc/web/wiklou.git]
/
includes
/
jobqueue
/
jobs
/
CategoryMembershipChangeJob.php
diff --git
a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
index
1828dd7
..
3a0063c
100644
(file)
--- a/
includes/jobqueue/jobs/CategoryMembershipChangeJob.php
+++ b/
includes/jobqueue/jobs/CategoryMembershipChangeJob.php
@@
-20,6
+20,7
@@
* @file
*/
use MediaWiki\MediaWikiServices;
* @file
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\LBFactory;
/**
* Job to add recent change entries mentioning category membership changes
/**
* Job to add recent change entries mentioning category membership changes
@@
-33,6
+34,9
@@
use MediaWiki\MediaWikiServices;
* @since 1.27
*/
class CategoryMembershipChangeJob extends Job {
* @since 1.27
*/
class CategoryMembershipChangeJob extends Job {
+ /** @var integer|null */
+ private $ticket;
+
const ENQUEUE_FUDGE_SEC = 60;
public function __construct( Title $title, array $params ) {
const ENQUEUE_FUDGE_SEC = 60;
public function __construct( Title $title, array $params ) {
@@
-43,23
+47,27
@@
class CategoryMembershipChangeJob extends Job {
}
public function run() {
}
public function run() {
+ $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+ $lb = $lbFactory->getMainLB();
+ $dbw = $lb->getConnection( DB_MASTER );
+
+ $this->ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
+
$page = WikiPage::newFromID( $this->params['pageId'], WikiPage::READ_LATEST );
if ( !$page ) {
$this->setLastError( "Could not find page #{$this->params['pageId']}" );
return false; // deleted?
}
$page = WikiPage::newFromID( $this->params['pageId'], WikiPage::READ_LATEST );
if ( !$page ) {
$this->setLastError( "Could not find page #{$this->params['pageId']}" );
return false; // deleted?
}
- $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
- $dbw = $lb->getConnection( DB_MASTER );
// Use a named lock so that jobs for this page see each others' changes
$lockKey = "CategoryMembershipUpdates:{$page->getId()}";
// Use a named lock so that jobs for this page see each others' changes
$lockKey = "CategoryMembershipUpdates:{$page->getId()}";
- $scopedLock = $dbw->getScopedLockAndFlush( $lockKey, __METHOD__,
10
);
+ $scopedLock = $dbw->getScopedLockAndFlush( $lockKey, __METHOD__,
3
);
if ( !$scopedLock ) {
$this->setLastError( "Could not acquire lock '$lockKey'" );
return false;
}
if ( !$scopedLock ) {
$this->setLastError( "Could not acquire lock '$lockKey'" );
return false;
}
- $dbr =
wfGetDB
( DB_REPLICA, [ 'recentchanges' ] );
+ $dbr =
$lb->getConnection
( DB_REPLICA, [ 'recentchanges' ] );
// Wait till the replica DB is caught up so that jobs for this page see each others' changes
if ( !$lb->safeWaitForMasterPos( $dbr ) ) {
$this->setLastError( "Timed out while waiting for replica DB to catch up" );
// Wait till the replica DB is caught up so that jobs for this page see each others' changes
if ( !$lb->safeWaitForMasterPos( $dbr ) ) {
$this->setLastError( "Timed out while waiting for replica DB to catch up" );
@@
-120,7
+128,6
@@
class CategoryMembershipChangeJob extends Job {
);
// Apply all category updates in revision timestamp order
);
// Apply all category updates in revision timestamp order
- $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
foreach ( $res as $row ) {
$this->notifyUpdatesForRevision( $lbFactory, $page, Revision::newFromRow( $row ) );
}
foreach ( $res as $row ) {
$this->notifyUpdatesForRevision( $lbFactory, $page, Revision::newFromRow( $row ) );
}
@@
-162,8
+169,6
@@
class CategoryMembershipChangeJob extends Job {
return; // nothing to do
}
return; // nothing to do
}
- $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
-
$catMembChange = new CategoryMembershipChange( $title, $newRev );
$catMembChange->checkTemplateLinks();
$catMembChange = new CategoryMembershipChange( $title, $newRev );
$catMembChange->checkTemplateLinks();
@@
-174,7
+179,7
@@
class CategoryMembershipChangeJob extends Job {
$categoryTitle = Title::makeTitle( NS_CATEGORY, $categoryName );
$catMembChange->triggerCategoryAddedNotification( $categoryTitle );
if ( $insertCount++ && ( $insertCount % $batchSize ) == 0 ) {
$categoryTitle = Title::makeTitle( NS_CATEGORY, $categoryName );
$catMembChange->triggerCategoryAddedNotification( $categoryTitle );
if ( $insertCount++ && ( $insertCount % $batchSize ) == 0 ) {
- $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
+ $lbFactory->commitAndWaitForReplication( __METHOD__, $t
his->t
icket );
}
}
}
}
@@
-182,7
+187,7
@@
class CategoryMembershipChangeJob extends Job {
$categoryTitle = Title::makeTitle( NS_CATEGORY, $categoryName );
$catMembChange->triggerCategoryRemovedNotification( $categoryTitle );
if ( $insertCount++ && ( $insertCount++ % $batchSize ) == 0 ) {
$categoryTitle = Title::makeTitle( NS_CATEGORY, $categoryName );
$catMembChange->triggerCategoryRemovedNotification( $categoryTitle );
if ( $insertCount++ && ( $insertCount++ % $batchSize ) == 0 ) {
- $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
+ $lbFactory->commitAndWaitForReplication( __METHOD__, $t
his->t
icket );
}
}
}
}
}
}