From 615d513f87d82f1f39f7eb5d1bc04a026ef25b82 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 3 Mar 2015 22:23:00 -0800 Subject: [PATCH] Profile wfShellExec() calls by caller Change-Id: Ide437ec586b9e123ca73b5abd17278a72375dfb0 --- includes/GlobalFunctions.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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() ) ); } /** -- 2.20.1