From 0e0fcf55a2f157beb2d32681cb358922ef88d900 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sat, 21 Jul 2012 22:35:05 +0200 Subject: [PATCH] Reorder methods in the MediaWiki class for better consistency. Change-Id: I651606b3d675212891c5075b3114c451810a3ec5 --- includes/Wiki.php | 172 +++++++++++++++++++++++----------------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/includes/Wiki.php b/includes/Wiki.php index 5f593e7e8c..4b84744c79 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -133,6 +133,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 @@ -291,34 +319,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. @@ -392,64 +392,6 @@ class MediaWiki { return $article; } - /** - * 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() { - // 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" ); - } - /** * Perform one of the "standard" actions * @@ -603,4 +545,62 @@ class MediaWiki { 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 ); + } + } } -- 2.20.1