MantisBT

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001133XdebugUsage problems (Wrong Results)public2015-03-31 03:152015-03-31 10:53
Reportertroydavisson 
Assigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformLinuxOSFedoraOS VersionFedora 21
Product Version2.3.1 
Target VersionFixed in Version2.3.3 
Summary0001133: PDO exception code value type is changed
DescriptionRunning 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 ReproduceWith 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 InformationA 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
Attached Files

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

-  Notes
(0003054)
derick (administrator)
2015-03-31 10:05

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.
(0003055)
derick (administrator)
2015-03-31 10:53

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 03:15 troydavisson New Issue
2015-03-31 10:05 derick Note Added: 0003054
2015-03-31 10:05 derick Assigned To => derick
2015-03-31 10:05 derick Status new => assigned
2015-03-31 10:53 derick Note Added: 0003055
2015-03-31 10:53 derick Status assigned => closed
2015-03-31 10:53 derick Resolution open => fixed
2015-03-31 10:53 derick Fixed in Version => 2.3.3
2015-06-18 10:31 derick Relationship added has duplicate 0001163
2015-06-18 10:32 derick Relationship added has duplicate 0001160
2016-07-31 13:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 13:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker