We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27376
    • 576 Posts
    I’ve just discovered after two days of investigation that PDO doesn’t work when the [tt]zend.ze1_compatibility_mode[/tt] option is enabled, doing so will result in a fatal error:
    Fatal error: Cannot clone object of class PDO due to 'zend.ze1_compatibility_mode' in /Users/webdev/Sites/MODx/pdo_test.php on line 24
    The reason I thought I’d share this here is because this error will not show up when trying to instantiate PDO within xPDO. All attempts left me with a blank screen in my browser. I finally narrowed it down to PDO when I created a test file that simply tried to create a PDO object. That’s when the error you see above came out.

    The only solution I can find right now is in to use an ’&’ in the [tt]xpdo.connect.php[/tt] file like so:
    Index: xpdo.connect.inc.php
    --- xpdo.connect.inc.php        (revision 160)
    +++ xpdo.connect.inc.php        (working copy)
    @@ -10,9 +10,9 @@
      * @package xpdo
     try {
    -    $this->pdo= new $pdo_classname($this->config['dsn'], $this->config['username'], $this->config['password'], $this->config['driverOptions']);
    +    $this->pdo=& new $pdo_classname($this->config['dsn'], $this->config['username'], $this->config['password'], $this->config['driverOptions']);
         $errorCode= $this->pdo->errorCode();
     } catch (PDOException $xe) {
         $this->pdo= null;
    -return (is_object($this->pdo) && (empty($errorCode) || $errorCode == PDO_ERR_NONE));
    \ No newline at end of file
    +return (is_object($this->pdo) && (empty($errorCode) || $errorCode == PDO_ERR_NONE));
    This will at least make the connection fail silently and continue execution. Anyone have any thoughts on this?
    • That seems to be a problematic bug in 5.0.x and 5.1.x -- I’m going to have to suggest that setting be turned off or you force xPDO into emulated mode and avoid using the native PDO in those versions if the compatibility mode cannot be turned off (though I’m not positive that will work any better).