Umherirrender has uploaded a new change for review. https://gerrit.wikimedia.org/r/104928
Change subject: Add JobQueueDB::selectFields and use it ...................................................................... Add JobQueueDB::selectFields and use it It is good practice to name the selected fields Change-Id: Ic12fbdbac6e8f48abbd9f5053a69f9553492cead --- M includes/job/JobQueueDB.php 1 file changed, 25 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/28/104928/1 diff --git a/includes/job/JobQueueDB.php b/includes/job/JobQueueDB.php index 79ff4e8..e7a269a 100644 --- a/includes/job/JobQueueDB.php +++ b/includes/job/JobQueueDB.php @@ -358,7 +358,7 @@ // Instead, this uses job_random to pick a row (possibly checking both directions). $ineq = $gte ? '>=' : '<='; $dir = $gte ? 'ASC' : 'DESC'; - $row = $dbw->selectRow( 'job', '*', // find a random job + $row = $dbw->selectRow( 'job', self::selectFields(), // find a random job array( 'job_cmd' => $this->type, 'job_token' => '', // unclaimed @@ -375,7 +375,7 @@ // Bug 42614: "ORDER BY job_random" with a job_random inequality causes high CPU // in MySQL if there are many rows for some reason. This uses a small OFFSET // instead of job_random for reducing excess claim retries. - $row = $dbw->selectRow( 'job', '*', // find a random job + $row = $dbw->selectRow( 'job', self::selectFields(), // find a random job array( 'job_cmd' => $this->type, 'job_token' => '', // unclaimed @@ -459,7 +459,7 @@ } // Fetch any row that we just reserved... if ( $dbw->affectedRows() ) { - $row = $dbw->selectRow( 'job', '*', + $row = $dbw->selectRow( 'job', self::selectFields(), array( 'job_cmd' => $this->type, 'job_token' => $uuid ), __METHOD__ ); if ( !$row ) { // raced out by duplicate job removal @@ -589,7 +589,7 @@ $dbr = $this->getSlaveDB(); try { return new MappedIterator( - $dbr->select( 'job', '*', + $dbr->select( 'job', self::selectFields(), array( 'job_cmd' => $this->getType(), 'job_token' => '' ) ), function ( $row ) use ( $dbr ) { $job = Job::factory( @@ -824,4 +824,25 @@ protected function throwDBException( DBError $e ) { throw new JobQueueError( get_class( $e ) . ": " . $e->getMessage() ); } + + /** + * Return the list of job fields that should be selected. + * @since 1.23 + * @return array + */ + public static function selectFields() { + return array( + 'job_id', + 'job_cmd', + 'job_namespace', + 'job_title', + 'job_timestamp', + 'job_params', + 'job_random', + 'job_attempts', + 'job_token', + 'job_token_timestamp', + 'job_sha1', + ); + } } -- To view, visit https://gerrit.wikimedia.org/r/104928 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic12fbdbac6e8f48abbd9f5053a69f9553492cead Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits