#48773 [NEW]: Incorrect error when setting PDO::ATTR_STATEMENT_CLASS with ctor_args

[email protected] ("saschagros at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
From:             saschagros at gmail dot com
Operating system: Linux
PHP version:      6CVS-2009-07-02 (snap)
PHP Bug Type:     PDO related
Bug description:  Incorrect error when setting PDO::ATTR_STATEMENT_CLASS with ctor_args

Description:
------------
I'm getting the following error when the ATTR_STATEMENT_CLASS option is
set...

Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000]: General error: PDO::ATTR_STATEMENT_CLASS requires format
array(classname, array(ctor_args)); the classname must be a string
specifying an existing class' in
..../drupal7/includes/database/database.inc:338

The same configuration works for PHP 5.2 and 5.3

The reproduce code is the constructor of the DatabaseConnection class of
Drupal 7, see also
http://cvs.drupal.org/viewvc.py/drupal/drupal/includes/database/database.inc?revision=1.57&view=markup

Reproduce code:
---------------
  function __construct($dsn, $username, $password, $driver_options =
array()) {
    // Because the other methods don't seem to work right.
    $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;

    // Call PDO::__construct and PDO::setAttribute.
    parent::__construct($dsn, $username, $password, $driver_options);

    // Set a specific PDOStatement class if the driver requires that.
    if (!empty($this->statementClass)) {
      $this->setAttribute(PDO::ATTR_STATEMENT_CLASS,
array($this->statementClass, array($this)));
    }
  }


Expected result:
----------------
The connection can be established....

Actual result:
--------------
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000]: General error: PDO::ATTR_STATEMENT_CLASS requires format
array(classname, array(ctor_args)); the classname must be a string
specifying an existing class' in
..../drupal7/includes/database/database.inc:338
Stack trace:
#0 .../drupal7/includes/database/database.inc(338): PDO->setAttribute(13,
Array)
#1 .../drupal7/includes/database/mysql/database.inc(36):
DatabaseConnection->__construct('mysql:host=loca...', 'd7', 'd7', Array)
#2 /.../drupal7/includes/database/database.inc(1350):
DatabaseConnection_mysql->__construct(Array)
#3 .../drupal7/includes/database/database.inc(1218):
Database::openConnection('default', 'default')
#4 .../drupal7/includes/database/database.inc(1793):
Database::getConnection('default')
#5 .../drupal7/includes/bootstrap.inc(1242): db_query('SELECT 1 FROM
{...', Array)


-- 
Edit bug report at http://bugs.php.net/?id=48773&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        http://bugs.php.net/fix.php?id=48773&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        http://bugs.php.net/fix.php?id=48773&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        http://bugs.php.net/fix.php?id=48773&r=trysnapshot60
Fixed in CVS:                        http://bugs.php.net/fix.php?id=48773&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48773&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=48773&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=48773&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=48773&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=48773&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=48773&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=48773&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=48773&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=48773&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=48773&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48773&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48773&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=48773&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=48773&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=48773&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=48773&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=48773&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.