[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Reorganize RefreshLinksJob code slightly and avoid deprecate...

2016-09-12 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Reorganize RefreshLinksJob code slightly and avoid deprecated 
functions
..


Reorganize RefreshLinksJob code slightly and avoid deprecated functions

Change-Id: I6ff4bec61b37bfbffc1e96eac61d692dd7feb31a
---
M includes/jobqueue/jobs/RefreshLinksJob.php
1 file changed, 10 insertions(+), 6 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/jobqueue/jobs/RefreshLinksJob.php 
b/includes/jobqueue/jobs/RefreshLinksJob.php
index a337da4..5f33ae0 100644
--- a/includes/jobqueue/jobs/RefreshLinksJob.php
+++ b/includes/jobqueue/jobs/RefreshLinksJob.php
@@ -88,7 +88,8 @@
// enqueued will be reflected in backlink page parses 
when the leaf jobs run.
if ( !isset( $params['range'] ) ) {
try {
-   wfGetLBFactory()->waitForReplication( [
+   $lbFactory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+   $lbFactory->waitForReplication( [
'wiki'=> wfWikiID(),
'timeout' => 
self::LAG_WAIT_TIMEOUT
] );
@@ -128,13 +129,18 @@
 * @return bool
 */
protected function runForTitle( Title $title ) {
-   $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
+   $services = MediaWikiServices::getInstance();
+   $stats = $services->getStatsdDataFactory();
+   $lbFactory = $services->getDBLoadBalancerFactory();
+   $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
 
$page = WikiPage::factory( $title );
$page->loadPageData( WikiPage::READ_LATEST );
 
// Serialize links updates by page ID so they see each others' 
changes
-   $scopedLock = LinksUpdate::acquirePageLock( wfGetDB( DB_MASTER 
), $page->getId(), 'job' );
+   $dbw = $lbFactory->getMainLB()->getConnection( DB_MASTER );
+   /** @noinspection PhpUnusedLocalVariableInspection */
+   $scopedLock = LinksUpdate::acquirePageLock( $dbw, 
$page->getId(), 'job' );
// Get the latest ID *after* acquirePageLock() flushed the 
transaction.
// This is used to detect edits/moves after loadPageData() but 
before the scope lock.
// The works around the chicken/egg problem of determining the 
scope lock key.
@@ -241,10 +247,7 @@
$parserOutput
);
 
-   $factory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
-   $ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
foreach ( $updates as $key => $update ) {
-   $update->setTransactionTicket( $ticket );
// FIXME: This code probably shouldn't be here?
// Needed by things like Echo notifications which need
// to know which user caused the links update
@@ -264,6 +267,7 @@
}
 
foreach ( $updates as $update ) {
+   $update->setTransactionTicket( $ticket );
$update->doUpdate();
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/310196
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6ff4bec61b37bfbffc1e96eac61d692dd7feb31a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz 
Gerrit-Reviewer: Krinkle 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Reorganize RefreshLinksJob code slightly and avoid deprecate...

2016-09-12 Thread Aaron Schulz (Code Review)
Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/310196

Change subject: Reorganize RefreshLinksJob code slightly and avoid deprecated 
functions
..

Reorganize RefreshLinksJob code slightly and avoid deprecated functions

Change-Id: I6ff4bec61b37bfbffc1e96eac61d692dd7feb31a
---
M includes/jobqueue/jobs/RefreshLinksJob.php
1 file changed, 10 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/96/310196/1

diff --git a/includes/jobqueue/jobs/RefreshLinksJob.php 
b/includes/jobqueue/jobs/RefreshLinksJob.php
index a337da4..5f33ae0 100644
--- a/includes/jobqueue/jobs/RefreshLinksJob.php
+++ b/includes/jobqueue/jobs/RefreshLinksJob.php
@@ -88,7 +88,8 @@
// enqueued will be reflected in backlink page parses 
when the leaf jobs run.
if ( !isset( $params['range'] ) ) {
try {
-   wfGetLBFactory()->waitForReplication( [
+   $lbFactory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+   $lbFactory->waitForReplication( [
'wiki'=> wfWikiID(),
'timeout' => 
self::LAG_WAIT_TIMEOUT
] );
@@ -128,13 +129,18 @@
 * @return bool
 */
protected function runForTitle( Title $title ) {
-   $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
+   $services = MediaWikiServices::getInstance();
+   $stats = $services->getStatsdDataFactory();
+   $lbFactory = $services->getDBLoadBalancerFactory();
+   $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
 
$page = WikiPage::factory( $title );
$page->loadPageData( WikiPage::READ_LATEST );
 
// Serialize links updates by page ID so they see each others' 
changes
-   $scopedLock = LinksUpdate::acquirePageLock( wfGetDB( DB_MASTER 
), $page->getId(), 'job' );
+   $dbw = $lbFactory->getMainLB()->getConnection( DB_MASTER );
+   /** @noinspection PhpUnusedLocalVariableInspection */
+   $scopedLock = LinksUpdate::acquirePageLock( $dbw, 
$page->getId(), 'job' );
// Get the latest ID *after* acquirePageLock() flushed the 
transaction.
// This is used to detect edits/moves after loadPageData() but 
before the scope lock.
// The works around the chicken/egg problem of determining the 
scope lock key.
@@ -241,10 +247,7 @@
$parserOutput
);
 
-   $factory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
-   $ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
foreach ( $updates as $key => $update ) {
-   $update->setTransactionTicket( $ticket );
// FIXME: This code probably shouldn't be here?
// Needed by things like Echo notifications which need
// to know which user caused the links update
@@ -264,6 +267,7 @@
}
 
foreach ( $updates as $update ) {
+   $update->setTransactionTicket( $ticket );
$update->doUpdate();
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/310196
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6ff4bec61b37bfbffc1e96eac61d692dd7feb31a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits