Skip to content

Commit

Permalink
bug #48624 [ErrorHandler][HttpKernel] Fix reading the SYMFONY_IDE env…
Browse files Browse the repository at this point in the history
… var (nicolas-grekas)

This PR was merged into the 6.1 branch.

Discussion
----------

[ErrorHandler][HttpKernel] Fix reading the SYMFONY_IDE env var

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Commits
-------

ac52802 [HttpKernel][ErrorHandler] Fix reading the SYMFONY_IDE env var
  • Loading branch information
nicolas-grekas committed Dec 13, 2022
2 parents c195e1d + ac52802 commit 7ed7e92
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ini name="intl.default_locale" value="en" />
<ini name="intl.error_level" value="0" />
<ini name="memory_limit" value="-1" />
<env name="SYMFONY_IDE" value="" force="true" />
<env name="DUMP_LIGHT_ARRAY" value="" />
<env name="DUMP_STRING_LENGTH" value="" />
<env name="LDAP_HOST" value="localhost" />
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
>
<php>
<ini name="error_reporting" value="-1" />
<env name="SYMFONY_IDE" value="" force="true" />
<env name="REDIS_HOST" value="localhost" />
<env name="MEMCACHED_HOST" value="localhost" />
</php>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(bool|callable $debug = false, string $charset = null
{
$this->debug = \is_bool($debug) ? $debug : $debug(...);
$this->charset = $charset ?: (\ini_get('default_charset') ?: 'UTF-8');
$fileLinkFormat ??= $_SERVER['SYMFONY_IDE'] ?? null;
$fileLinkFormat ??= $_ENV['SYMFONY_IDE'] ?? $_SERVER['SYMFONY_IDE'] ?? null;
$this->fileLinkFormat = \is_string($fileLinkFormat)
? (ErrorRendererInterface::IDE_LINK_FORMATS[$fileLinkFormat] ?? $fileLinkFormat ?: false)
: ($fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: false);
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/ErrorHandler/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
>
<php>
<ini name="error_reporting" value="-1" />
<env name="SYMFONY_IDE" value="" force="true" />
</php>

<testsuites>
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class FileLinkFormatter
*/
public function __construct(string|array $fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, string|\Closure $urlFormat = null)
{
$fileLinkFormat ??= $_SERVER['SYMFONY_IDE'] ?? '';
$fileLinkFormat ??= $_ENV['SYMFONY_IDE'] ?? $_SERVER['SYMFONY_IDE'] ?? '';

if (!\is_array($fileLinkFormat) && $fileLinkFormat = (ErrorRendererInterface::IDE_LINK_FORMATS[$fileLinkFormat] ?? $fileLinkFormat) ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: false) {
$i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f);
$fileLinkFormat = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, \PREG_SPLIT_DELIM_CAPTURE);
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpKernel/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
>
<php>
<ini name="error_reporting" value="-1" />
<env name="SYMFONY_IDE" value="" force="true" />
</php>

<testsuites>
Expand Down

0 comments on commit 7ed7e92

Please sign in to comment.