View Issue Details

IDProjectCategoryView StatusLast Update
0001133XdebugUncategorizedpublic2015-03-31 09:53
Reportertroydavisson Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSFedoraOS VersionFedora 21
Product Version2.3.1 
Fixed in Version2.3.3 
Summary0001133: PDO exception code value type is changed
Description

Running PHP 5.6.6 with Xdebug enabled, executing a PDO query which causes an exception to be thrown causes the value returned by $e->getCode() to have it's type changed. Running PHP 5.5.* with Xdebug enabled does not produce the same result, suggesting a recent change.

Steps To Reproduce

With Xdebug enabled, execute:

<?php

try {
$pdo = new PDO("sqlite::memory:");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->query("INSERT INTO fake_table VALUES ('bogus')");
} catch (PDOException $e) {
var_dump($e->getCode());
var_dump($e->getMessage());
}

Disable Xdebug and execute again. With Xdebug on, the exception code is int(0). With Xdebug disabled, it's string(5) "HY000"

Additional Information

A slightly more realistic example against MySQL (all other code the same) returns:

string(5) "42S02"

with Xdebug disabled and:

int(42)

with Xdebug enabled, suggesting that there's extra value casting happening now that didn't exist in prior versions.

TagsNo tags attached.
Operating SystemFedora 21
PHP Version5.6.0-5.6.4

Relationships

has duplicate 0001163 resolvedderick XDebug casts exception codes to integer 
has duplicate 0001160 resolvedderick xdebug is still stricter than PHP regarding the code property type 

Activities

derick

2015-03-31 09:05

administrator   ~0003054

No need for PDO here, this also fails:

php -r 'try { throw new Exception("foo", "42GG"); } catch (Exception $e) { echo $e->getCode(), "\n"; }'

echos:

42

-- I see what the problem is. "Just" need to fix it now.

derick

2015-03-31 09:53

administrator   ~0003055

It was PDO specific after all, as the standard Exception requires "code" to be an integer. I've fixed it for 2.3.3/3.0.0. Thanks for the report!

Issue History

Date Modified Username Field Change
2015-03-31 02:15 troydavisson New Issue
2015-03-31 09:05 derick Note Added: 0003054
2015-03-31 09:05 derick Assigned To => derick
2015-03-31 09:05 derick Status new => assigned
2015-03-31 09:53 derick Note Added: 0003055
2015-03-31 09:53 derick Status assigned => closed
2015-03-31 09:53 derick Resolution open => fixed
2015-03-31 09:53 derick Fixed in Version => 2.3.3
2015-06-18 09:31 derick Relationship added has duplicate 0001163
2015-06-18 09:32 derick Relationship added has duplicate 0001160
2016-07-31 12:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 12:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized