Unbreak --profile=text for CLI scrips
authorAaron Schulz <aschulz@wikimedia.org>
Sat, 9 May 2015 01:59:42 +0000 (18:59 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 9 May 2015 02:09:31 +0000 (19:09 -0700)
* Fixes "Undefined index: threshold" and
  "Invalid argument supplied for foreach()" errors
  so that output actually can show

Change-Id: Ibf8090f265d988c58d1752319336a5146a28f4d0

maintenance/Maintenance.php

index 3f804a0..c97c6a3 100644 (file)
@@ -603,7 +603,7 @@ abstract class Maintenance {
         * Activate the profiler (assuming $wgProfiler is set)
         */
        protected function activateProfiler() {
-               global $wgProfiler, $wgTrxProfilerLimits;
+               global $wgProfiler, $wgProfileLimit, $wgTrxProfilerLimits;
 
                $output = $this->getOption( 'profiler' );
                if ( !$output ) {
@@ -613,7 +613,9 @@ abstract class Maintenance {
                if ( is_array( $wgProfiler ) && isset( $wgProfiler['class'] ) ) {
                        $class = $wgProfiler['class'];
                        $profiler = new $class(
-                               array( 'sampling' => 1, 'output' => $output ) + $wgProfiler
+                               array( 'sampling' => 1, 'output' => array( $output ) )
+                                       + $wgProfiler
+                                       + array( 'threshold' => $wgProfileLimit )
                        );
                        $profiler->setTemplated( true );
                        Profiler::replaceStubInstance( $profiler );