diff options
author | Dmitry Stogov <dmitry@zend.com> | 2019-02-19 18:09:44 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2019-02-19 18:09:44 +0300 |
commit | 26ab6edffc6c4b925f09d74253edec28f550edf6 (patch) | |
tree | fc9d7642ab2a45f2a790d3deb574d9db1a47b329 | |
parent | d9094d4d6455811c2bd9f23511ec0adbdb607b4f (diff) | |
download | php-git-26ab6edffc6c4b925f09d74253edec28f550edf6.tar.gz |
Accurate handling of not preloaded classes
-rw-r--r-- | ext/opcache/ZendAccelerator.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 38e60c5a16..7dbce7738e 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3281,6 +3281,15 @@ static void preload_link(void) if ((ce->ce_flags & (ZEND_ACC_TOP_LEVEL|ZEND_ACC_ANON_CLASS)) && !(ce->ce_flags & ZEND_ACC_LINKED)) { + if (!(ce->ce_flags & ZEND_ACC_ANON_CLASS)) { + key = zend_string_tolower(ce->name); + if (zend_hash_exists(EG(class_table), key)) { + zend_string_release(key); + continue; + } + zend_string_release(key); + } + parent = NULL; if (ce->parent_name) { @@ -3332,9 +3341,10 @@ static void preload_link(void) if (!found) continue; } - key = zend_string_tolower(ce->name); + zend_string *key = zend_string_tolower(ce->name); zv = zend_hash_set_bucket_key(EG(class_table), (Bucket*)zv, key); zend_string_release(key); + if (EXPECTED(zv)) { /* Set filename & lineno information for inheritance errors */ CG(in_compilation) = 1; @@ -3461,7 +3471,13 @@ static void preload_link(void) break; } if (!(ce->ce_flags & ZEND_ACC_LINKED)) { - zend_error(E_WARNING, "Can't preload unlinked class %s at %s:%d", ZSTR_VAL(ce->name), ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start); + zend_string *key = zend_string_tolower(ce->name); + if (zend_hash_exists(EG(class_table), key)) { + zend_error(E_WARNING, "Can't preload already declared class %s at %s:%d", ZSTR_VAL(ce->name), ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start); + } else { + zend_error(E_WARNING, "Can't preload unlinked class %s at %s:%d", ZSTR_VAL(ce->name), ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start); + } + zend_string_release(key); } else if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { zend_error(E_WARNING, "Can't preload class %s with unresolved constants at %s:%d", ZSTR_VAL(ce->name), ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start); } else if (!(ce->ce_flags & ZEND_ACC_PROPERTY_TYPES_RESOLVED)) { @@ -3513,8 +3529,7 @@ static void preload_link(void) case ZEND_DECLARE_INHERITED_CLASS: case ZEND_DECLARE_INHERITED_CLASS_DELAYED: key = Z_STR_P(RT_CONSTANT(opline, opline->op1) + 1); - zv = zend_hash_find_ex(EG(class_table), key, 1); - if (EXPECTED(!zv)) { + if (!zend_hash_exists(&script->script.class_table, key)) { MAKE_NOP(opline); } break; |