Skip to content

Fix delayed early binding class redeclaration error #11226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Zend/tests/delayed_early_binding_redeclaration-1.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
class Bar extends Foo {}
2 changes: 2 additions & 0 deletions Zend/tests/delayed_early_binding_redeclaration-2.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
class Bar extends Foo {}
13 changes: 13 additions & 0 deletions Zend/tests/delayed_early_binding_redeclaration.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Delayed early binding throws class redeclaration error
--EXTENSIONS--
opcache
--FILE--
<?php
class Foo {}
include __DIR__ . '/delayed_early_binding_redeclaration-1.inc';
include __DIR__ . '/delayed_early_binding_redeclaration-2.inc';
var_dump(class_exists(Bar::class));
?>
--EXPECTF--
Fatal error: Cannot declare class Bar, because the name is already in use in %sdelayed_early_binding_redeclaration-2.inc on line %d
6 changes: 3 additions & 3 deletions ext/opcache/zend_accelerator_util_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ static void zend_accel_do_delayed_early_binding(
ce = zend_try_early_bind(orig_ce, parent_ce, early_binding->lcname, zv);
}
}
}
if (ce && early_binding->cache_slot != (uint32_t) -1) {
*(void**)((char*)run_time_cache + early_binding->cache_slot) = ce;
if (ce && early_binding->cache_slot != (uint32_t) -1) {
*(void**)((char*)run_time_cache + early_binding->cache_slot) = ce;
}
}
}
CG(compiled_filename) = orig_compiled_filename;
Expand Down