X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=maintenance%2FMaintenance.php;h=2f8b7d2b1213a7ec693c82f9b75a81458905a9fc;hb=85500c240dd18f460cdabf37b669d610cf520400;hp=d740f56bbf21ed1a2996d8c248a2cd965fdd6667;hpb=0e17070d4028fa6c2ead49ea01a264ddde40dfc1;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index d740f56bbf..2f8b7d2b12 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -102,7 +102,7 @@ abstract class Maintenance { private $mDependantParameters = array(); /** - * Used by getDD() / setDB() + * Used by getDB() / setDB() * @var DatabaseBase */ private $mDb = null; @@ -446,7 +446,7 @@ abstract class Maintenance { $this->addOption( 'server', "The protocol and server name to use in URLs, e.g. " . "http://en.wikipedia.org. This is sometimes necessary because " . "server name detection may fail in command line scripts.", false, true ); - $this->addOption( 'profiler', 'Set to "text" or "trace" to show profiling output', false, true ); + $this->addOption( 'profiler', 'Profiler output format (usually "text")', false, true ); # Save generic options to display them separately in help $this->mGenericParameters = $this->mParams; @@ -597,6 +597,23 @@ abstract class Maintenance { } } + /** + * Activate the profiler (assuming $wgProfiler is set) + */ + protected function activateProfiler() { + global $wgProfiler; + + $output = $this->getOption( 'profiler' ); + if ( $output && is_array( $wgProfiler ) ) { + $class = $wgProfiler['class']; + $profiler = new $class( + array( 'sampling' => 1, 'output' => $output ) + $wgProfiler + ); + $profiler->setTemplated( true ); + Profiler::replaceStubInstance( $profiler ); + } + } + /** * Clear all params and arguments. */ @@ -920,26 +937,19 @@ abstract class Maintenance { LBFactory::destroyInstance(); } + // Per-script profiling; useful for debugging + $this->activateProfiler(); + $this->afterFinalSetup(); $wgShowSQLErrors = true; - // @codingStandardsIgnoreStart Allow error supppression. wfSuppressWarnings() - // is not avaiable. + // @codingStandardsIgnoreStart Allow error suppression. wfSuppressWarnings() + // is not available. @set_time_limit( 0 ); // @codingStandardsIgnoreStart $this->adjustMemoryLimit(); - - // Per-script profiling; useful for debugging - $forcedProfiler = $this->getOption( 'profiler' ); - if ( $forcedProfiler === 'text' ) { - Profiler::setInstance( new ProfilerSimpleText( array() ) ); - Profiler::instance()->setTemplated( true ); - } elseif ( $forcedProfiler === 'trace' ) { - Profiler::setInstance( new ProfilerSimpleTrace( array() ) ); - Profiler::instance()->setTemplated( true ); - } } /** @@ -1174,7 +1184,7 @@ abstract class Maintenance { * We default as considering stdin a tty (for nice readline methods) * but treating stout as not a tty to avoid color codes * - * @param int $fd File descriptor + * @param mixed $fd File descriptor * @return bool */ public static function posix_isatty( $fd ) { @@ -1311,7 +1321,7 @@ abstract class LoggedUpdateMaintenance extends Maintenance { } /** - * Message to show the the update log was unable to log the completion of this update + * Message to show that the update log was unable to log the completion of this update * @return string */ protected function updatelogFailedMessage() {