Merge "Changing default copyright notice per WMF Legal's suggestion."
[lhc/web/wiklou.git] / maintenance / Maintenance.php
index 98b7d47..0023c6d 100644 (file)
@@ -426,6 +426,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 );
 
                # Save generic options to display them separately in help
                $this->mGenericParameters = $this->mParams;
@@ -452,11 +453,11 @@ abstract class Maintenance {
         */
        public function runChild( $maintClass, $classFile = null ) {
                // Make sure the class is loaded first
-               if ( !MWInit::classExists( $maintClass ) ) {
+               if ( !class_exists( $maintClass ) ) {
                        if ( $classFile ) {
                                require_once $classFile;
                        }
-                       if ( !MWInit::classExists( $maintClass ) ) {
+                       if ( !class_exists( $maintClass ) ) {
                                $this->error( "Cannot spawn child: $maintClass" );
                        }
                }
@@ -877,6 +878,16 @@ abstract class Maintenance {
                $wgShowSQLErrors = true;
                @set_time_limit( 0 );
                $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 );
+               }
        }
 
        /**
@@ -1144,8 +1155,7 @@ abstract class Maintenance {
                        $title = $titleObj->getPrefixedDBkey();
                        $this->output( "$title..." );
                        # Update searchindex
-                       # TODO: pass the Content object to SearchUpdate, let the search engine decide how to deal with it.
-                       $u = new SearchUpdate( $pageId, $titleObj->getText(), $rev->getContent()->getTextForSearchIndex() );
+                       $u = new SearchUpdate( $pageId, $titleObj->getText(), $rev->getContent() );
                        $u->doUpdate();
                        $this->output( "\n" );
                }
@@ -1161,7 +1171,7 @@ abstract class Maintenance {
         * @return bool
         */
        public static function posix_isatty( $fd ) {
-               if ( !MWInit::functionExists( 'posix_isatty' ) ) {
+               if ( !function_exists( 'posix_isatty' ) ) {
                        return !$fd;
                } else {
                        return posix_isatty( $fd );