Replay warnings during inheritance (#6928)

Since 3e6b447979 it is again possible to have
warnings (deprecations) during inheritance, and more such functionality is
likely in the future. This is a problem, because such warnings will only be
shown on the first request if the opcache inheritance cache is used. This
currently causes test failures in --repeat builds.

Fix this by uplifting the error recording functionality from opcache to Zend,
and then using it to persist a warning trace in the inheritance cache, which
can then be used to replay the warnings on subsequent executions.
This commit is contained in:
Nikita Popov 2021-04-29 16:37:53 +02:00 committed by GitHub
parent f84936b30c
commit dd86987b2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 103 additions and 72 deletions

View file

@ -2681,6 +2681,10 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
}
return ret;
}
/* Make sure warnings (such as deprecations) thrown during inheritance
* will be recoreded in the inheritance cache. */
zend_begin_record_errors();
} else {
is_cacheable = 0;
}
@ -2751,6 +2755,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
}
zend_build_properties_info_table(ce);
EG(record_errors) = false;
if (!(ce->ce_flags & ZEND_ACC_UNRESOLVED_VARIANCE)) {
ce->ce_flags |= ZEND_ACC_LINKED;
@ -2796,6 +2801,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
}
}
zend_free_recorded_errors();
if (traits_and_interfaces) {
free_alloca(traits_and_interfaces, use_heap);
}