Skip to content

Commit

Permalink
AutoloadSourceLocator - fix opcache corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Apr 29, 2022
1 parent bc000e8 commit ae53760
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -28,6 +28,7 @@
use function interface_exists;
use function is_file;
use function is_string;
use function opcache_invalidate;
use function restore_error_handler;
use function set_error_handler;
use function spl_autoload_functions;
Expand Down Expand Up @@ -334,7 +335,7 @@ private function locateClassByName(string $className): ?array

try {
/** @var array{string, string, null}|null */
return FileReadTrapStreamWrapper::withStreamWrapperOverride(
$result = FileReadTrapStreamWrapper::withStreamWrapperOverride(
static function () use ($className): ?array {
$functions = spl_autoload_functions();
if ($functions === false) {
Expand All @@ -358,6 +359,13 @@ static function () use ($className): ?array {
return null;
},
);
if ($result === null) {
return null;
}

opcache_invalidate($result[0], true);

This comment has been minimized.

Copy link
@mvorisek

mvorisek Apr 29, 2022

Contributor

this may have negative performance, is this known to fix any issue?

This comment has been minimized.

Copy link
@dktapps

dktapps Apr 30, 2022

Contributor

see discussion in #801


return $result;
} finally {
restore_error_handler();
}
Expand Down

0 comments on commit ae53760

Please sign in to comment.