* Retieves key/value pairs to circumvent global variables
* Note that keys are case-insensitive!
*/
- function getVal( $key, $default = "" ) {
+ function getVal( $key, $default = '' ) {
$key = strtolower( $key );
if( isset( $this->params[$key] ) ) {
return $this->params[$key];
// Do this above the read whitelist check for security...
$title = Title::makeTitle( NS_SPECIAL, 'Search' );
}
- $this->setVal( "Search", $search );
+ $this->setVal( 'Search', $search );
# If the user is not logged in, the Namespace:title of the article must be in
# the Read array in order for the user to see it. (We have to check here to
$article = $this->articleFromTitle( $title );
// Namespace might change when using redirects
- if( $action == 'view' && !$request->getVal( 'oldid' ) && $request->getVal( 'redirect' ) != 'no' ) {
+ if( $action == 'view' && !$request->getVal( 'oldid' ) &&
+ $request->getVal( 'redirect' ) != 'no' ) {
$dbr=&wfGetDB(DB_SLAVE);
- $article->loadPageData($article->pageDataFromTitle($dbr,$title));
+
+ // If we don't check for existance we'll get "Trying to get
+ // property of non-object" E_NOTICE in Article::loadPageData() when
+ // viewing a page that does not exist
+ if ( $article->exists() ) {
+ $article->loadPageData($article->pageDataFromTitle($dbr,$title));
+ }
+
/* Follow redirects only for... redirects */
if ($article->mIsRedirect) {
$target = $article->followRedirect();
}
}
if( is_object( $target ) ) {
- // evil globals hack!
/* Rewrite environment to redirected article */
- $rarticle =& new Article($target);
+ $rarticle = $this->articleFromTitle($target);
$rarticle->loadPageData($rarticle->pageDataFromTitle($dbr,$target));
if ($rarticle->mTitle->mArticleID) {
- $article =& $rarticle;
- $wgTitle =& $target;
+ $article = $rarticle;
+ $wgTitle = $target;
$article->setRedirectedFrom( $title );
} else {
- $wgTitle =& $title;
+ $wgTitle = $title;
}
}
} else {
- $wgTitle =& $article->mTitle;
+ $wgTitle = $article->mTitle;
}
}
wfProfileOut( 'MediaWiki::initializeArticle' );
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();
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 );
+ }
+ }
}
/**
$action = $this->getVal('Action');
if( in_array( $action, $this->getVal('DisabledActions',array()) ) ) {
/* No such action; this will switch to the default case */
- $action = "nosuchaction";
+ $action = 'nosuchaction';
}
switch( $action ) {
if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) {
$output->errorpage( 'nosuchaction', 'nosuchactiontext' );
}
+ }
wfProfileOut( 'MediaWiki::performAction' );
- }
}