Don't trigger PHP errors for unused Shell\Command
[lhc/web/wiklou.git] / includes / shell / Command.php
index 4fc282c..a16f4af 100644 (file)
@@ -83,12 +83,14 @@ class Command {
         */
        public function __destruct() {
                if ( !$this->everExecuted ) {
+                       $context = [ 'command' => $this->command ];
                        $message = __CLASS__ . " was instantiated, but execute() was never called.";
                        if ( $this->method ) {
-                               $message .= " Calling method: {$this->method}.";
+                               $message .= ' Calling method: {method}.';
+                               $context['method'] = $this->method;
                        }
-                       $message .= " Command: {$this->command}";
-                       trigger_error( $message, E_USER_NOTICE );
+                       $message .= ' Command: {command}';
+                       $this->logger->warning( $message, $context );
                }
        }
 
@@ -253,7 +255,7 @@ class Command {
                if ( !$useLogPipe && $this->useStderr ) {
                        $cmd .= ' 2>&1';
                }
-               wfDebug( __METHOD__ . ": $cmd\n" );
+               $this->logger->debug( __METHOD__ . ": $cmd" );
 
                // Don't try to execute commands that exceed Linux's MAX_ARG_STRLEN.
                // Other platforms may be more accomodating, but we don't want to be