8000 bug #34886 [HttpKernel] fix triggering deprecation in file locator (x… · symfony/symfony@6bf764a · GitHub
[go: up one dir, main page]

Skip to content

Commit 6bf764a

Browse files
committed
bug #34886 [HttpKernel] fix triggering deprecation in file locator (xabbuh)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpKernel] fix triggering deprecation in file locator | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #34556 | License | MIT | Doc PR | Commits ------- 142b179 fix triggering deprecation in file locator
2 parents 648544f + 142b179 commit 6bf764a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/Symfony/Component/HttpKernel/Config/FileLocator.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,24 @@ public function locate($file, $currentPath = null, $first = true)
6565
|| (\strlen($file) > 3 && ctype_alpha($file[0]) && ':' === $file[1] && ('\\' === $file[2] || '/' === $file[2]))
6666
|| null !== parse_url($file, PHP_URL_SCHEME)
6767
)) {
68+
$triggerDeprecation = false;
69+
6870
// no need to trigger deprecations when the loaded file is given as absolute path
6971
foreach ($this->paths as $deprecatedPath) {
70-
if (\is_array($locations)) {
71-
foreach ($locations as $location) {
72-
if (0 === strpos($location, $deprecatedPath) && (null === $currentPath || false === strpos($location, $currentPath))) {
73-
@trigger_error(sprintf('Loading the file "%s" from the global resource directory "%s" is deprecated since Symfony 4.4 and will be removed in 5.0.', $file, $deprecatedPath), E_USER_DEPRECATED);
74-
}
72+
foreach ((array) $locations as $location) {
73+
if (null !== $currentPath && 0 === strpos($location, $currentPath)) {
74+
return $locations;
7575
}
76-
} else {
77-
if (0 === strpos($locations, $deprecatedPath) && (null === $currentPath || false === strpos($locations, $currentPath))) {
78-
@trigger_error(sprintf('Loading the file "%s" from the global resource directory "%s" is deprecated since Symfony 4.4 and will be removed in 5.0.', $file, $deprecatedPath), E_USER_DEPRECATED);
76+
77+
if (0 === strpos($location, $deprecatedPath) && (null === $currentPath || false === strpos($location, $currentPath))) {
78+
$triggerDeprecation = true;
7979
}
8080
}
8181
}
82+
83+
if ($triggerDeprecation) {
84+
@trigger_error(sprintf('Loading the file "%s" from the global resource directory "%s" is deprecated since Symfony 4.4 and will be removed in 5.0.', $file, $deprecatedPath), E_USER_DEPRECATED);
85+
}
8286
}
8387

8488
return $locations;

0 commit comments

Comments
 (0)
0