ZF-8035: Zend_Queue_Adapter_Db could not instantinate Pdo_Pgsql adapter

Description

Hello

While testing Zend_Queue with PostgreSQL database I`ve received error message:

{{SQLSTATE[08006] [7] invalid connection option "type"}}

The problem is that "driverOptions" requires key "type" which is later passed to Zend_Db_Adapter_Pdo_Abstract. This key is used to create _dsn() (see: Zend/Db/Adapter/Pdo/Abstract.php line 74). Unfortunately key "type" is incorrect for PostgreSQL database (MySQL does not yelled an error).

The fix for this issue is trivial:

in Zend/Queue/Adapter/Db.php change from line 91:

if (!array_key_exists('type', $options)) {
            require_once 'Zend/Queue/Exception.php';
            throw new Zend_Queue_Exception("Configuration array must have a key for 'type' for the database type to use");
        }

into:

if (!array_key_exists('type', $options)) {
            require_once 'Zend/Queue/Exception.php';
            throw new Zend_Queue_Exception("Configuration array must have a key for 'type' for the database type to use");
        } else {
                $dbType = $options['type'];
                unset( $options['type'] );
        }

and later in this file, change line 120: from:

$db = Zend_Db::factory( $options['type'], $options);

into:

$db = Zend_Db::factory( $dbType, $options);

Regards

MichaƂ Bachowski

Comments

fixing typos ;-)

Duplicate of ZF-7651