* @defgroup Maintenance Maintenance
*/
-// Make sure we're on PHP5.3.2 or better
-if ( !function_exists( 'version_compare' ) || version_compare( PHP_VERSION, '5.3.2' ) < 0 ) {
+// Make sure we're on PHP5.3.3 or better
+if ( !function_exists( 'version_compare' ) || version_compare( PHP_VERSION, '5.3.3' ) < 0 ) {
// We need to use dirname( __FILE__ ) here cause __DIR__ is PHP5.3+
require_once dirname( __FILE__ ) . '/../includes/PHPVersionError.php';
wfPHPVersionError( 'cli' );
private $mDependantParameters = array();
/**
- * Used by getDD() / setDB()
+ * Used by getDB() / setDB()
* @var DatabaseBase
*/
private $mDb = null;
$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;
}
}
+ /**
+ * 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.
*/
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 );
- }
}
/**
* 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 ) {
}
/**
- * 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() {