Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit990b51b

Browse files
committed
bug#40629 [DependencyInjection] Fix "url" env var processor behavior when the url has no path (fancyweb)
This PR was merged into the 4.4 branch.Discussion----------[DependencyInjection] Fix "url" env var processor behavior when the url has no path| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets | -| License | MIT| Doc PR | -Before:```yamlMY_URL_ENV_VAR=http://symfony.com%env(key:path:url:MY_URL_ENV_VAR)% --> false```After:```yamlMY_URL_ENV_VAR=http://symfony.com%env(key:path:url:MY_URL_ENV_VAR)% --> null```Returning `false` for the path prevents me from using the `default` env var processor that is triggered only for `''` and `null`.(`%env(default:my_fallback_param:key:path:url:MY_URL_ENV_VAR)%`)BTW, with PHP 8, it actually works because `substr(null, 1)` behavior changed (seehttps://3v4l.org/oHf6l).Commits-------2876cf9 [DependencyInjection] Fix "url" env var processor behavior when the url has no path
2 parents2ceb35a +2876cf9 commit990b51b

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

‎src/Symfony/Component/DependencyInjection/EnvVarProcessor.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,10 @@ public function getEnv($prefix, $name, \Closure $getEnv)
255255
'fragment' =>null,
256256
];
257257

258-
// remove the '/' separator
259-
$parsedEnv['path'] ='/' ===$parsedEnv['path'] ?null :substr($parsedEnv['path'],1);
258+
if (null !==$parsedEnv['path']) {
259+
// remove the '/' separator
260+
$parsedEnv['path'] ='/' ===$parsedEnv['path'] ?null :substr($parsedEnv['path'],1);
261+
}
260262

261263
return$parsedEnv;
262264
}

‎src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,4 +610,26 @@ public function testGetEnvInvalidPrefixWithDefault()
610610
returnnull;
611611
});
612612
}
613+
614+
/**
615+
* @dataProvider provideGetEnvUrlPath
616+
*/
617+
publicfunctiontestGetEnvUrlPath(?string$expected,string$url)
618+
{
619+
$this->assertSame($expected, (newEnvVarProcessor(newContainer()))->getEnv('url','foo',staticfunction ()use ($url):string {
620+
return$url;
621+
})['path']);
622+
}
623+
624+
publicfunctionprovideGetEnvUrlPath()
625+
{
626+
return [
627+
[null,'https://symfony.com'],
628+
[null,'https://symfony.com/'],
629+
['/','https://symfony.com//'],
630+
['blog','https://symfony.com/blog'],
631+
['blog/','https://symfony.com/blog/'],
632+
['blog//','https://symfony.com/blog//'],
633+
];
634+
}
613635
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp