Skip to content

Commit e6674d9

Browse files
committed
Add a workaround for PHP PDO SQLite bug (#79664) in PHP < 7.3
See also: php/php-src#5654
1 parent b759bf9 commit e6674d9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,27 @@ private function execute_select_statement( WP_Parser_Node $node ): void {
14261426
// seems to erase type information for expressions in the SELECT clause.
14271427
$this->last_column_meta = array();
14281428
for ( $i = 0; $i < $stmt->columnCount(); $i++ ) {
1429+
/*
1430+
* Workaround for PHP PDO SQLite bug (#79664) in PHP < 7.3.
1431+
* See also: https://github.com/php/php-src/pull/5654
1432+
*/
1433+
if ( PHP_VERSION_ID < 70300 ) {
1434+
try {
1435+
$this->last_column_meta[] = $stmt->getColumnMeta( $i );
1436+
} catch ( Throwable $e ) {
1437+
$this->last_column_meta[] = array(
1438+
'native_type' => 'null',
1439+
'pdo_type' => PDO::PARAM_NULL,
1440+
'flags' => array(),
1441+
'table' => '',
1442+
'name' => '',
1443+
'len' => -1,
1444+
'precision' => 0,
1445+
);
1446+
}
1447+
continue;
1448+
}
1449+
14291450
$this->last_column_meta[] = $stmt->getColumnMeta( $i );
14301451
}
14311452

0 commit comments

Comments
 (0)