jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/384914 )

Change subject: Don't trigger PHP errors for unused Shell\Command
......................................................................


Don't trigger PHP errors for unused Shell\Command

Change-Id: Id29da4f21a44ccb18d8a2ae11348d69ca3233aa5
---
M includes/shell/Command.php
M tests/phpunit/includes/shell/CommandTest.php
2 files changed, 5 insertions(+), 14 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/shell/Command.php b/includes/shell/Command.php
index 59f40bf..a16f4af 100644
--- a/includes/shell/Command.php
+++ b/includes/shell/Command.php
@@ -83,12 +83,14 @@
         */
        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 );
                }
        }
 
diff --git a/tests/phpunit/includes/shell/CommandTest.php 
b/tests/phpunit/includes/shell/CommandTest.php
index 34434b9..32d855e 100644
--- a/tests/phpunit/includes/shell/CommandTest.php
+++ b/tests/phpunit/includes/shell/CommandTest.php
@@ -6,17 +6,6 @@
  * @group Shell
  */
 class CommandTest extends PHPUnit_Framework_TestCase {
-       /**
-        * @expectedException PHPUnit_Framework_Error_Notice
-        */
-       public function testDestruct() {
-               if ( defined( 'HHVM_VERSION' ) ) {
-                       $this->markTestSkipped( 'destructors are unreliable in 
HHVM' );
-               }
-               $command = new Command();
-               $command->params( 'true' );
-       }
-
        private function requirePosix() {
                if ( wfIsWindows() ) {
                        $this->markTestSkipped( 'This test requires a POSIX 
environment.' );

-- 
To view, visit https://gerrit.wikimedia.org/r/384914
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id29da4f21a44ccb18d8a2ae11348d69ca3233aa5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MaxSem <maxsem.w...@gmail.com>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to