Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/208352
Change subject: Moved FRExtraCacheUpdateJob to a separate file ...................................................................... Moved FRExtraCacheUpdateJob to a separate file Change-Id: I2935810663e16e87f8a25af1dce432cd56001762 --- M backend/FRExtraCacheUpdate.php A backend/FRExtraCacheUpdateJob.php 2 files changed, 68 insertions(+), 68 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlaggedRevs refs/changes/52/208352/1 diff --git a/backend/FRExtraCacheUpdate.php b/backend/FRExtraCacheUpdate.php old mode 100644 new mode 100755 index 54311ca..59ecedf --- a/backend/FRExtraCacheUpdate.php +++ b/backend/FRExtraCacheUpdate.php @@ -131,71 +131,3 @@ } } } - -/** - * Job class for handling deferred FRExtraCacheUpdates - * @ingroup JobQueue - */ -class FRExtraCacheUpdateJob extends Job { - /** - * Construct a job - * @param Title $title The title linked to - * @param array $params Job parameters (table, start and end page_ids) - */ - function __construct( $title, $params ) { - parent::__construct( 'flaggedrevs_CacheUpdate', $title, $params ); - - $this->params['type'] = isset( $this->params['type'] ) - ? $this->params['type'] - : 'purge'; - } - - function run() { - if ( $this->params['type'] === 'purge' ) { - $this->doBacklinkPurge(); - } elseif ( $this->params['type'] === 'updatelinks' ) { - $this->doUpdateLinks(); - } else { - throw new InvalidArgumentException( "Missing 'type' parameter." ); - } - } - - protected function doBacklinkPurge() { - $update = new FRExtraCacheUpdate( $this->title ); - # Get query conditions - $fromField = $update->getFromField(); - $conds = $update->getToCondition(); - if ( $this->params['start'] ) { - $conds[] = "$fromField >= {$this->params['start']}"; - } - if ( $this->params['end'] ) { - $conds[] = "$fromField <= {$this->params['end']}"; - } - # Run query to get page Ids - $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( $this->params['table'], $fromField, $conds, __METHOD__ ); - # Invalidate the pages - $update->invalidateIDs( $res ); - return true; - } - - protected function doUpdateLinks() { - $fpage = FlaggableWikiPage::getTitleInstance( $this->title ); - $srev = $fpage->getStableRev(); - if ( $srev ) { - $pOpts = $fpage->makeParserOptions( 'canonical' ); - $stableOut = FlaggedRevs::parseStableRevision( $srev, $pOpts ); - - if ( $stableOut ) { - // Update the stable-only dependency links right now - $frDepUpdate = new FRDependencyUpdate( $this->title, $stableOut ); - $frDepUpdate->doUpdate( FRDependencyUpdate::IMMEDIATE ); - - return; - } - } - - // If not page or revision was found, remove the stable-only links - FlaggedRevs::clearStableOnlyDeps( $fpage->getId() ); - } -} diff --git a/backend/FRExtraCacheUpdateJob.php b/backend/FRExtraCacheUpdateJob.php new file mode 100755 index 0000000..d13cd24 --- /dev/null +++ b/backend/FRExtraCacheUpdateJob.php @@ -0,0 +1,68 @@ +<?php +/** + * Job class for handling deferred FRExtraCacheUpdates + * @ingroup JobQueue + */ +class FRExtraCacheUpdateJob extends Job { + /** + * Construct a job + * @param Title $title The title linked to + * @param array $params Job parameters (table, start and end page_ids) + */ + function __construct( $title, $params ) { + parent::__construct( 'flaggedrevs_CacheUpdate', $title, $params ); + + $this->params['type'] = isset( $this->params['type'] ) + ? $this->params['type'] + : 'purge'; + } + + function run() { + if ( $this->params['type'] === 'purge' ) { + $this->doBacklinkPurge(); + } elseif ( $this->params['type'] === 'updatelinks' ) { + $this->doUpdateLinks(); + } else { + throw new InvalidArgumentException( "Missing 'type' parameter." ); + } + } + + protected function doBacklinkPurge() { + $update = new FRExtraCacheUpdate( $this->title ); + # Get query conditions + $fromField = $update->getFromField(); + $conds = $update->getToCondition(); + if ( $this->params['start'] ) { + $conds[] = "$fromField >= {$this->params['start']}"; + } + if ( $this->params['end'] ) { + $conds[] = "$fromField <= {$this->params['end']}"; + } + # Run query to get page Ids + $dbr = wfGetDB( DB_SLAVE ); + $res = $dbr->select( $this->params['table'], $fromField, $conds, __METHOD__ ); + # Invalidate the pages + $update->invalidateIDs( $res ); + return true; + } + + protected function doUpdateLinks() { + $fpage = FlaggableWikiPage::getTitleInstance( $this->title ); + $srev = $fpage->getStableRev(); + if ( $srev ) { + $pOpts = $fpage->makeParserOptions( 'canonical' ); + $stableOut = FlaggedRevs::parseStableRevision( $srev, $pOpts ); + + if ( $stableOut ) { + // Update the stable-only dependency links right now + $frDepUpdate = new FRDependencyUpdate( $this->title, $stableOut ); + $frDepUpdate->doUpdate( FRDependencyUpdate::IMMEDIATE ); + + return; + } + } + + // If not page or revision was found, remove the stable-only links + FlaggedRevs::clearStableOnlyDeps( $fpage->getId() ); + } +} -- To view, visit https://gerrit.wikimedia.org/r/208352 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2935810663e16e87f8a25af1dce432cd56001762 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/FlaggedRevs Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits