From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/Wiki.php | 199 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 103 insertions(+), 96 deletions(-) (limited to 'includes/Wiki.php') diff --git a/includes/Wiki.php b/includes/Wiki.php index 6ead57c4..a4a89032 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -62,7 +62,6 @@ class MediaWiki { } $this->context = $context; - $this->context->setTitle( $this->parseTitle() ); } /** @@ -133,6 +132,34 @@ class MediaWiki { return $this->context->getTitle(); } + /** + * Returns the name of the action that will be executed. + * + * @return string: action + */ + public function getAction() { + static $action = null; + + if ( $action === null ) { + $action = Action::getActionName( $this->context ); + } + + return $action; + } + + /** + * Create an Article object of the appropriate class for the given page. + * + * @deprecated in 1.18; use Article::newFromTitle() instead + * @param $title Title + * @param $context IContextSource + * @return Article object + */ + public static function articleFromTitle( $title, IContextSource $context ) { + wfDeprecated( __METHOD__, '1.18' ); + return Article::newFromTitle( $title, $context ); + } + /** * Performs the request. * - bad titles @@ -269,11 +296,10 @@ class MediaWiki { $pageView = true; /** * $wgArticle is deprecated, do not use it. - * This will be removed entirely in 1.20. * @deprecated since 1.18 */ global $wgArticle; - $wgArticle = $article; + $wgArticle = new DeprecatedGlobal( 'wgArticle', $article, '1.18' ); $this->performAction( $article ); } elseif ( is_string( $article ) ) { @@ -292,34 +318,6 @@ class MediaWiki { wfProfileOut( __METHOD__ ); } - /** - * Create an Article object of the appropriate class for the given page. - * - * @deprecated in 1.18; use Article::newFromTitle() instead - * @param $title Title - * @param $context IContextSource - * @return Article object - */ - public static function articleFromTitle( $title, IContextSource $context ) { - wfDeprecated( __METHOD__, '1.18' ); - return Article::newFromTitle( $title, $context ); - } - - /** - * Returns the name of the action that will be executed. - * - * @return string: action - */ - public function getAction() { - static $action = null; - - if ( $action === null ) { - $action = Action::getActionName( $this->context ); - } - - return $action; - } - /** * Initialize the main Article object for "standard" actions (view, etc) * Create an Article object for the page, following redirects if needed. @@ -393,76 +391,14 @@ class MediaWiki { return $article; } - /** - * Cleaning up request by doing deferred updates, DB transaction, and the output - */ - public function finalCleanup() { - wfProfileIn( __METHOD__ ); - // Now commit any transactions, so that unreported errors after - // output() don't roll back the whole DB transaction - $factory = wfGetLBFactory(); - $factory->commitMasterChanges(); - // Output everything! - $this->context->getOutput()->output(); - // Do any deferred jobs - DeferredUpdates::doUpdates( 'commit' ); - $this->doJobs(); - wfProfileOut( __METHOD__ ); - } - - /** - * Do a job from the job queue - */ - private function doJobs() { - global $wgJobRunRate; - - if ( $wgJobRunRate <= 0 || wfReadOnly() ) { - return; - } - if ( $wgJobRunRate < 1 ) { - $max = mt_getrandmax(); - if ( mt_rand( 0, $max ) > $max * $wgJobRunRate ) { - return; - } - $n = 1; - } else { - $n = intval( $wgJobRunRate ); - } - - while ( $n-- && false != ( $job = Job::pop() ) ) { - $output = $job->toString() . "\n"; - $t = - microtime( true ); - $success = $job->run(); - $t += microtime( true ); - $t = round( $t * 1000 ); - if ( !$success ) { - $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n"; - } else { - $output .= "Success, Time: $t ms\n"; - } - wfDebugLog( 'jobqueue', $output ); - } - } - - /** - * Ends this task peacefully - */ - public function restInPeace() { - MessageCache::logMessages(); - wfLogProfilingData(); - // Commit and close up! - $factory = wfGetLBFactory(); - $factory->commitMasterChanges(); - $factory->shutdown(); - wfDebug( "Request ended normally\n" ); - } - /** * Perform one of the "standard" actions * * @param $page Page */ private function performAction( Page $page ) { + global $wgUseSquid, $wgSquidMaxage; + wfProfileIn( __METHOD__ ); $request = $this->context->getRequest(); @@ -481,6 +417,13 @@ class MediaWiki { $action = Action::factory( $act, $page ); if ( $action instanceof Action ) { + # Let Squid cache things if we can purge them. + if ( $wgUseSquid && + in_array( $request->getFullRequestURL(), $title->getSquidURLs() ) + ) { + $output->setSquidMaxage( $wgSquidMaxage ); + } + $action->show(); wfProfileOut( __METHOD__ ); return; @@ -591,8 +534,72 @@ class MediaWiki { } $this->performRequest(); - $this->finalCleanup(); + + // Now commit any transactions, so that unreported errors after + // output() don't roll back the whole DB transaction + wfGetLBFactory()->commitMasterChanges(); + + // Output everything! + $this->context->getOutput()->output(); wfProfileOut( __METHOD__ ); } + + /** + * Ends this task peacefully + */ + public function restInPeace() { + // Do any deferred jobs + DeferredUpdates::doUpdates( 'commit' ); + + // Execute a job from the queue + $this->doJobs(); + + // Log message usage, if $wgAdaptiveMessageCache is set to true + MessageCache::logMessages(); + + // Log profiling data, e.g. in the database or UDP + wfLogProfilingData(); + + // Commit and close up! + $factory = wfGetLBFactory(); + $factory->commitMasterChanges(); + $factory->shutdown(); + + wfDebug( "Request ended normally\n" ); + } + + /** + * Do a job from the job queue + */ + private function doJobs() { + global $wgJobRunRate; + + if ( $wgJobRunRate <= 0 || wfReadOnly() ) { + return; + } + if ( $wgJobRunRate < 1 ) { + $max = mt_getrandmax(); + if ( mt_rand( 0, $max ) > $max * $wgJobRunRate ) { + return; + } + $n = 1; + } else { + $n = intval( $wgJobRunRate ); + } + + while ( $n-- && false != ( $job = Job::pop() ) ) { + $output = $job->toString() . "\n"; + $t = - microtime( true ); + $success = $job->run(); + $t += microtime( true ); + $t = round( $t * 1000 ); + if ( !$success ) { + $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n"; + } else { + $output .= "Success, Time: $t ms\n"; + } + wfDebugLog( 'jobqueue', $output ); + } + } } -- cgit v1.2.3-54-g00ecf