Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Follow-up to #2463285: Support PHP7 EngineExceptions in the error handler
Problem/Motivation
PHP 7 adds a custom error class, similar to exceptions.
Before this issue, we listened to BaseExceptions which was replaced by the Throwable interface in https://wiki.php.net/rfc/throwable-interface
Proposed resolution
Use Throwable.
Remaining tasks
User interface changes
N/A
API changes
N/A
Comment | File | Size | Author |
---|---|---|---|
#18 | 2505315-18.patch | 5.92 KB | stefan.r |
#18 | interdiff-15-18.txt | 2.89 KB | stefan.r |
#16 | 2505315-15.patch | 6.01 KB | stefan.r |
#16 | interdiff-12-15.txt | 1.09 KB | stefan.r |
#12 | interdiff.txt | 3.11 KB | stefan.r |
Comments
Comment #1
stefan.r CreditAttribution: stefan.r commentedPer the RFC at https://wiki.php.net/rfc/throwable-interface
So probably no need to rename the Error class, and just alias where necessary?
Comment #2
stefan.r CreditAttribution: stefan.r commentedComment #3
stefan.r CreditAttribution: stefan.r commentedComment #4
stefan.r CreditAttribution: stefan.r commentedI guess this would need to be postponed on the change actually getting into the PHP7 master branch.
Comment #5
tim.plunkettGiven the current RFC, couldn't this be
@param \ThrowableInterface $exception
?Do we want to switch to $error from $exception2?
Comment #6
stefan.r CreditAttribution: stefan.r commentedYes that makes sense, PHP5 doesn't have ThrowableInterface but we can probably live with that...
Comment #7
stefan.r CreditAttribution: stefan.r commentedComment #8
stefan.r CreditAttribution: stefan.r commentedSeems this was merged last week: https://github.com/php/php-src/pull/1284
Could anyone do a test run on PHP7 master?
Comment #10
BerdirNot sure about this, since it only exists in PHP 7? Should we use \Exception|\ThrowableInterface maybe?
This fixes the test fail but there's still an exception because we don't unset an assertion anymore a bit below this. Change TypeException to TypeError there.
Comment #11
anavarreComment #12
stefan.r CreditAttribution: stefan.r commentedComment #13
dawehnerThis IS is a little bit confusing. It talks about rename the error class, so is this something which still needs to be done?
On top of that I'm reading https://wiki.php.net/rfc/throwable-interface and
ThrowableInterface
is the base of both \Error and \ExceptionI understant that we need to catch both \Exception and \Throwable due to the PHP 5 compatibility
So those cases could catch the interface itself. Maybe new ones are introduced in the future, you never know.
Comment #14
stefan.r CreditAttribution: stefan.r commentedPer the RFC the Error class shouldn't have to be renamed: https://wiki.php.net/rfc/throwable-interface
Comment #15
dawehnerRight, because its not a scalar type but rather a proper namespaced class.
This makes sense, updated the issue summary.
The code improvement suggestion in #13 is still true
Comment #16
stefan.r CreditAttribution: stefan.r commentedComment #17
stefan.r CreditAttribution: stefan.r commentedComment #18
stefan.r CreditAttribution: stefan.r commentedComment #19
dawehnerHehe, yeah that name is a bit confusing, but this is life.
Comment #20
alexpottI ran the changed test in PHP7 - all looks good. Committed a8f8b33 and pushed to 8.0.x. Thanks!