Skip to content

Commit d120a8d

Browse files
committed
Use the PHP default for PDO::ATTR_STRINGIFY_FETCHES
1 parent bab7cd3 commit d120a8d

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

tests/WP_PDO_MySQL_On_SQLite_PDO_API_Tests.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class WP_PDO_MySQL_On_SQLite_PDO_API_Tests extends TestCase {
88

99
public function setUp(): void {
1010
$this->driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp;' );
11+
12+
// Set "PDO::ATTR_STRINGIFY_FETCHES" to "false" explicitly, so the tests
13+
// are consistent across PHP versions ("false" is the default from 8.1).
14+
$this->driver->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, false );
1115
}
1216

1317
public function test_connection(): void {

wp-includes/sqlite-ast/class-wp-pdo-mysql-on-sqlite.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ class WP_PDO_MySQL_On_SQLite extends PDO {
451451
* @var array<int, mixed>
452452
*/
453453
private $pdo_attributes = array(
454+
PDO::ATTR_STRINGIFY_FETCHES => PHP_VERSION_ID < 80100 ? true : false,
454455
);
455456

456457
/**

wp-includes/sqlite-ast/class-wp-sqlite-connection.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ public function __construct( array $options ) {
9191
}
9292
$this->pdo->setAttribute( PDO::ATTR_TIMEOUT, $timeout );
9393

94-
// Return all values (except null) as strings.
95-
$this->pdo->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true );
96-
9794
// Configure SQLite journal mode.
9895
$journal_mode = $options['journal_mode'] ?? null;
9996
if ( $journal_mode && in_array( $journal_mode, self::SQLITE_JOURNAL_MODES, true ) ) {

wp-includes/sqlite-ast/class-wp-sqlite-driver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public function __construct(
7474
);
7575
$this->main_db_name = $database;
7676
$this->client_info = $this->mysql_on_sqlite_driver->client_info;
77+
78+
$connection->get_pdo()->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, true );
7779
}
7880

7981
/**

0 commit comments

Comments
 (0)