replace TYPE= with ENGINE=, (supported since 4.0, TYPE deprecated since 4.1)
[lhc/web/wiklou.git] / includes / Wiki.php
index 407a3b6..0a0bd42 100644 (file)
@@ -202,7 +202,7 @@ class MediaWiki {
                $article = $this->articleFromTitle( $title );
                
                // Namespace might change when using redirects
-               if( $action == 'view' && !$request->getVal( 'oldid' ) && 
+               if( $action == 'view' && !$request->getVal( 'oldid' ) &&
                                                $request->getVal( 'redirect' ) != 'no' ) {
                        $dbr=&wfGetDB(DB_SLAVE);
                        
@@ -249,6 +249,7 @@ class MediaWiki {
        function finalCleanup ( &$deferredUpdates, &$loadBalancer, &$output ) {
                wfProfileIn( 'MediaWiki::finalCleanup' );
                $this->doUpdates( $deferredUpdates );
+               $this->doJobs();
                $loadBalancer->saveMasterPos();
                # Now commit any transactions, so that unreported errors after output() don't roll back the whole thing
                $loadBalancer->commitAll();
@@ -266,7 +267,39 @@ class MediaWiki {
                foreach( $updates as $up ) {
                        $up->doUpdate();
                }
-               wfProfileOut( 'MediaWiki::doUpdates' );         
+               wfProfileOut( 'MediaWiki::doUpdates' );
+       }
+
+       /**
+        * Do a job from the job queue
+        */
+       function doJobs() {
+               global $wgJobLogFile, $wgJobRunRate;
+               
+               if ( $wgJobRunRate <= 0 ) {
+                       return;
+               }
+               if ( $wgJobRunRate < 1 ) {
+                       $max = mt_getrandmax();
+                       if ( mt_rand( 0, $max ) > $max * $wgJobRunRate ) {
+                               return;
+                       }
+                       $n = 1;
+               } else {
+                       $n = intval( $wgJobRunRate );
+               }
+
+               require_once( 'JobQueue.php' );
+
+               while ( $n-- && false != ($job = Job::pop())) {
+                       $output = $job->toString() . "\n";
+                       if ( !$job->run() ) {
+                               $output .= "Error: " . $job->getLastError() . "\n";
+                       }
+                       if ( $wgJobLogFile ) {
+                               error_log( $output, 3, $wgJobLogFile );
+                       }
+               }
        }
        
        /**
@@ -375,8 +408,8 @@ class MediaWiki {
                                if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) {
                                        $output->errorpage( 'nosuchaction', 'nosuchactiontext' );
                                }
+               }
                wfProfileOut( 'MediaWiki::performAction' );
-       }
 
        
        }