From ce19bcd992a71d599bb1b214b64f47888dd62bad Mon Sep 17 00:00:00 2001 From: John Stevenson Date: Tue, 13 Apr 2021 08:59:06 +0100 Subject: [PATCH] Upgrade to xdebug-handler 2 (#9832) This adds support for Xdebug3 modes and changes the default behaviour from always restarting if Xdebug is loaded, to only restarting if Xdebug is active. Xdebug is considered active if it is loaded, and for Xdebug3, if it is running in a mode other than `xdebug.mode=off`. --- bin/composer | 2 +- composer.json | 2 +- composer.lock | 28 ++++++++++++------------ src/Composer/Command/DiagnoseCommand.php | 4 +++- src/Composer/Console/Application.php | 4 +++- tests/Composer/Test/ApplicationTest.php | 3 ++- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/bin/composer b/bin/composer index cadff6d0d..2e83cdd19 100755 --- a/bin/composer +++ b/bin/composer @@ -14,7 +14,7 @@ use Composer\XdebugHandler\XdebugHandler; error_reporting(-1); // Restart without Xdebug -$xdebug = new XdebugHandler('Composer', '--ansi'); +$xdebug = new XdebugHandler('Composer'); $xdebug->check(); unset($xdebug); diff --git a/composer.json b/composer.json index 3434fc1f5..2734e96e0 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "composer/metadata-minifier": "^1.0", "composer/semver": "^3.0", "composer/spdx-licenses": "^1.2", - "composer/xdebug-handler": "^1.1", + "composer/xdebug-handler": "^2.0", "justinrainbow/json-schema": "^5.2.10", "psr/log": "^1.0", "seld/jsonlint": "^1.4", diff --git a/composer.lock b/composer.lock index 466cd983f..360beb9d6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2587e14c10bc64959963a6f91f5ada71", + "content-hash": "723e5a1bc304dba4f21c6adf2b8f1cb2", "packages": [ { "name": "composer/ca-bundle", @@ -313,16 +313,16 @@ }, { "name": "composer/xdebug-handler", - "version": "1.4.6", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "f27e06cd9675801df441b3656569b328e04aa37c" + "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", - "reference": "f27e06cd9675801df441b3656569b328e04aa37c", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/964adcdd3a28bf9ed5d9ac6450064e0d71ed7496", + "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496", "shasum": "" }, "require": { @@ -357,7 +357,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/1.4.6" + "source": "https://github.com/composer/xdebug-handler/tree/2.0.1" }, "funding": [ { @@ -373,7 +373,7 @@ "type": "tidelift" } ], - "time": "2021-03-25T17:01:18+00:00" + "time": "2021-05-05T19:37:51+00:00" }, { "name": "justinrainbow/json-schema", @@ -447,16 +447,16 @@ }, { "name": "psr/log", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", "shasum": "" }, "require": { @@ -480,7 +480,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for logging libraries", @@ -491,9 +491,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.3" + "source": "https://github.com/php-fig/log/tree/1.1.4" }, - "time": "2020-03-23T09:12:05+00:00" + "time": "2021-05-03T11:20:27+00:00" }, { "name": "react/promise", diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 5f35fc4c5..dfbf90823 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -27,6 +27,8 @@ use Composer\Util\StreamContextFactory; use Composer\SelfUpdate\Keys; use Composer\SelfUpdate\Versions; use Composer\IO\NullIO; +use Composer\Package\CompletePackageInterface; +use Composer\XdebugHandler\XdebugHandler; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\ExecutableFinder; @@ -534,7 +536,7 @@ EOT if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) { $warnings['xdebug_profile'] = true; - } elseif (extension_loaded('xdebug')) { + } elseif (XdebugHandler::isXdebugActive()) { $warnings['xdebug_loaded'] = true; } diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 9d3557e27..ba1f6400e 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -33,6 +33,8 @@ use Composer\Util\ErrorHandler; use Composer\Util\HttpDownloader; use Composer\EventDispatcher\ScriptExecutionException; use Composer\Exception\NoSslException; +use Composer\XdebugHandler\XdebugHandler; +use Symfony\Component\Process\Exception\ProcessTimedOutException; /** * The console application that handles the commands @@ -236,7 +238,7 @@ class Application extends BaseApplication $io->writeError('Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.'); } - if (extension_loaded('xdebug') && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) { + if (XdebugHandler::isXdebugActive() && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) { $io->writeError('Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug'); } diff --git a/tests/Composer/Test/ApplicationTest.php b/tests/Composer/Test/ApplicationTest.php index 7cecb5794..31fdcd1ec 100644 --- a/tests/Composer/Test/ApplicationTest.php +++ b/tests/Composer/Test/ApplicationTest.php @@ -13,6 +13,7 @@ namespace Composer\Test; use Composer\Console\Application; +use Composer\XdebugHandler\XdebugHandler; use Symfony\Component\Console\Output\OutputInterface; class ApplicationTest extends TestCase @@ -54,7 +55,7 @@ class ApplicationTest extends TestCase $outputMock->expects($this->at($index++)) ->method("write"); - if (extension_loaded('xdebug')) { + if (XdebugHandler::isXdebugActive()) { $outputMock->expects($this->at($index++)) ->method("getVerbosity") ->willReturn(OutputInterface::VERBOSITY_NORMAL);