diff --git a/library/Zend/Db/Adapter/Pdo/Sqlite.php b/library/Zend/Db/Adapter/Pdo/Sqlite.php index 5b71b99eed..5babd670a6 100644 --- a/library/Zend/Db/Adapter/Pdo/Sqlite.php +++ b/library/Zend/Db/Adapter/Pdo/Sqlite.php @@ -91,6 +91,14 @@ public function __construct(array $config = []) $this->_config['username'] = null; $this->_config['password'] = null; + if (PHP_VERSION_ID >= 80100) { + // ensure $config['driver_options'] is an array + $config['driver_options'] = $config['driver_options'] ?? []; + if (!isset($config['driver_options'][PDO::ATTR_STRINGIFY_FETCHES])) { + $config['driver_options'][PDO::ATTR_STRINGIFY_FETCHES] = true; + } + } + return parent::__construct($config); } diff --git a/tests/Zend/Db/Adapter/Pdo/SqliteTest.php b/tests/Zend/Db/Adapter/Pdo/SqliteTest.php index 3df6b87c1d..06d4784a15 100644 --- a/tests/Zend/Db/Adapter/Pdo/SqliteTest.php +++ b/tests/Zend/Db/Adapter/Pdo/SqliteTest.php @@ -261,4 +261,26 @@ public function testAdapterQuoteNullByteCharacter() $value = $this->_db->quote($string); $this->assertEquals("'1\\000'", $value); } + + /** + * https://www.php.net/manual/en/migration81.incompatible.php#migration81.incompatible.pdo.sqlite + * @inheritDoc + */ + public function testAdapterZendConfigEmptyDriverOptions() + { + $params = $this->_util->getParams(); + $params['driver_options'] = []; + $params = new Zend_Config($params); + + $db = Zend_Db::factory($this->getDriver(), $params); + $db->getConnection(); + + $config = $db->getConfig(); + + if (PHP_VERSION_ID >= 80100) { + $this->assertEquals([PDO::ATTR_STRINGIFY_FETCHES => true], $config['driver_options']); + } else { + $this->assertEquals([], $config['driver_options']); + } + } }