From: Chad Horohoe Date: Wed, 4 Mar 2015 06:23:00 +0000 (-0800) Subject: Profile wfShellExec() calls by caller X-Git-Tag: 1.31.0-rc.0~12181^2 X-Git-Url: http://git.cyclocoop.org/data/%24self?a=commitdiff_plain;h=615d513f87d82f1f39f7eb5d1bc04a026ef25b82;p=lhc%2Fweb%2Fwiklou.git Profile wfShellExec() calls by caller Change-Id: Ide437ec586b9e123ca73b5abd17278a72375dfb0 --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 3f1062054c..869b7e0759 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2757,6 +2757,8 @@ function wfShellExecDisabled() { * @param array $options Array of options: * - duplicateStderr: Set this to true to duplicate stderr to stdout, * including errors from limit.sh + * - profileMethod: By default this function will profile based on the calling + * method. Set this to a string for an alternative method to profile from * * @return string Collected stdout as a string */ @@ -2775,6 +2777,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), } $includeStderr = isset( $options['duplicateStderr'] ) && $options['duplicateStderr']; + $profileMethod = isset( $options['profileMethod'] ) ? $options['profileMethod'] : wfGetCaller(); wfInitShellLocale(); @@ -2848,6 +2851,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), $desc[3] = array( 'pipe', 'w' ); } $pipes = null; + $scoped = Profiler::instance()->scopedProfileIn( __FUNCTION__ . '-' . $profileMethod ); $proc = proc_open( $cmd, $desc, $pipes ); if ( !$proc ) { wfDebugLog( 'exec', "proc_open() failed: $cmd" ); @@ -2999,7 +3003,8 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), * @return string Collected stdout and stderr as a string */ function wfShellExecWithStderr( $cmd, &$retval = null, $environ = array(), $limits = array() ) { - return wfShellExec( $cmd, $retval, $environ, $limits, array( 'duplicateStderr' => true ) ); + return wfShellExec( $cmd, $retval, $environ, $limits, + array( 'duplicateStderr' => true, 'profileMethod' => wfGetCaller() ) ); } /**