summaryrefslogtreecommitdiff
path: root/includes/Wiki.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
commit63601400e476c6cf43d985f3e7b9864681695ed4 (patch)
treef7846203a952e38aaf66989d0a4702779f549962 /includes/Wiki.php
parent8ff01378c9e0207f9169b81966a51def645b6a51 (diff)
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
Diffstat (limited to 'includes/Wiki.php')
-rw-r--r--includes/Wiki.php199
1 files changed, 103 insertions, 96 deletions
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() );
}
/**
@@ -134,6 +133,34 @@ class MediaWiki {
}
/**
+ * 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
* - read restriction
@@ -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 ) ) {
@@ -293,34 +319,6 @@ class MediaWiki {
}
/**
- * 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.
*
@@ -394,75 +392,13 @@ class MediaWiki {
}
/**
- * 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 );
+ }
+ }
}