(bug 27336) Add $wgJobTypesExcludedFromDefaultQueue for job types that aren't suppose...
authorRoan Kattouw <catrope@users.mediawiki.org>
Sun, 20 Mar 2011 16:52:57 +0000 (16:52 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sun, 20 Mar 2011 16:52:57 +0000 (16:52 +0000)
includes/DefaultSettings.php
includes/job/JobQueue.php

index e1c1806..17ad00a 100644 (file)
@@ -4651,6 +4651,18 @@ $wgJobClasses = array(
  */
 $wgExcludeFromThumbnailPurge = array();
 
+/**
+
+ * Jobs that must be explicitly requested, i.e. aren't run by job runners unless special flags are set.
+ * 
+ * These can be:
+ * - Very long-running jobs.
+ * - Jobs that you would never want to run as part of a page rendering request.
+ * - Jobs that you want to run on specialized machines ( like transcoding, or a particular
+ *   machine on your cluster has 'outside' web access you could restrict uploadFromUrl )
+ */
+$wgJobTypesExcludedFromDefaultQueue = array();
+
 /**
  * Additional functions to be performed with updateSpecialPages.
  * Expensive Querypages are already updated.
index 34f23b4..90bc98c 100644 (file)
@@ -95,6 +95,7 @@ abstract class Job {
         * @return Job or false if there's no jobs
         */
        static function pop( $offset = 0 ) {
+               global $wgJobTypesExcludedFromDefaultQueue;
                wfProfileIn( __METHOD__ );
 
                $dbr = wfGetDB( DB_SLAVE );
@@ -105,16 +106,23 @@ abstract class Job {
                        NB: If random fetch previously was used, offset
                                will always be ahead of few entries
                */
-
-               $row = $dbr->selectRow( 'job', '*', "job_id >= ${offset}", __METHOD__,
-                       array( 'ORDER BY' => 'job_id', 'LIMIT' => 1 ) );
+               $conditions = array();
+               if ( count( $wgJobTypesExcludedFromDefaultQueue ) != 0 ) {
+                       foreach ( $wgJobTypesExcludedFromDefaultQueue as $cmdType ) {
+                               $conditions[] = "job_cmd != " . $dbr->addQuotes( $cmdType );
+                       }
+               }
+               $offset = intval( $offset );
+               $row = $dbr->selectRow( 'job', '*', array_merge( $conditions, array( "job_id >= $offset" ) ) , __METHOD__,
+                       array( 'ORDER BY' => 'job_id', 'LIMIT' => 1 ) 
+               );
 
                // Refetching without offset is needed as some of job IDs could have had delayed commits
                // and have lower IDs than jobs already executed, blame concurrency :)
                //
                if ( $row === false ) {
                        if ( $offset != 0 ) {
-                               $row = $dbr->selectRow( 'job', '*', '', __METHOD__,
+                               $row = $dbr->selectRow( 'job', '*', $conditions, __METHOD__,
                                        array( 'ORDER BY' => 'job_id', 'LIMIT' => 1 ) );
                        }