View Issue Details

IDProjectCategoryView StatusLast Update
0001758XdebugUncategorizedpublic2020-03-13 16:40
Reporteralenore Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.9.2 
Target Version2.9.3Fixed in Version2.9.3 
Summary0001758: Xdebug changes error_get_last results inside a try catch
Description

When an error is caught in a try statement (since PHP 7.x), PHP doesn't update the last_error_message, last_error_file, last_error_type, and last_error_lineno variables.
error_get_last() would just return null in this case.

However, when Xdebug is installed, these variables get replaced before the error_handling is checked, and populate the variables even if it shouldn't

It's happening in 2.8.1, 3.0.0-dev and 2.9.2.

Steps To Reproduce

Install php7.4, enable Xdebug, then execute this script. It should display "true" (error_get_last return null), but display "false" (the error from our incorrect DateTime format).

<?php
register_shutdown_function(function () {
var_dump(is_null(error_get_last()));
});

try {
new DateTime('Incorrect value');
} catch (Exception $e) { }

Tagserror_get_last
Operating System
PHP Version7.4.0-7.4.4

Activities

derick

2020-03-12 14:28

administrator   ~0005285

It looks like this has changed in PHP itself between PHP 7.2 and PHP 7.3 (notice the -n, which means Xdebug isn't loaded):


derick@gargleblaster:~/dev/php/derickr-xdebug$ pe 7.2dev; php -n tests/base/bug01758.phpt
array(4) {
["type"]=>
int(2)
["message"]=>
string(137) "DateTime::__construct(): Failed to parse time string (Incorrect value) at position 0 (I): The timezone could not be found in the database"
["file"]=>
string(60) "/home/derick/dev/php/derickr-xdebug/tests/base/bug01758.phpt"
["line"]=>
int(7)
}

derick@gargleblaster:~/dev/php/derickr-xdebug$ pe 7.3dev; php -n tests/base/bug01758.phpt
NULL

Issue History

Date Modified Username Field Change
2020-03-06 17:31 alenore New Issue
2020-03-06 17:31 alenore Tag Attached: error_get_last
2020-03-12 14:28 derick Note Added: 0005285
2020-03-12 16:09 derick Status new => assigned
2020-03-12 16:09 derick Target Version => 2.9.3
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized
2020-03-13 16:40 derick Assigned To => derick
2020-03-13 16:40 derick Status assigned => closed
2020-03-13 16:40 derick Resolution open => fixed
2020-03-13 16:40 derick Fixed in Version => 2.9.3