File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -8170,4 +8170,29 @@ public function testColumnInfoWithZeroRows(): void {
8170
8170
$ column_info
8171
8171
);
8172
8172
}
8173
+
8174
+ public function testColumnInfoWithZeroRowsPhpBug (): void {
8175
+ if ( PHP_VERSION_ID < 70300 ) {
8176
+ $ this ->markTestSkipped ( 'Skipping due to PHP bug (#79664) ' );
8177
+ }
8178
+
8179
+ $ this ->assertQuery ( 'CREATE TABLE t ( id INT ) ' );
8180
+ $ this ->assertQuery ( 'SELECT * FROM t ' );
8181
+ $ this ->assertEquals ( 1 , $ this ->engine ->get_last_column_count () );
8182
+ $ column_info = $ this ->engine ->get_last_column_meta ();
8183
+ $ this ->assertCount ( 1 , $ column_info );
8184
+ $ this ->assertSame (
8185
+ array (
8186
+ 'native_type ' => 'LONG ' ,
8187
+ 'pdo_type ' => PDO ::PARAM_INT ,
8188
+ 'flags ' => array (),
8189
+ 'table ' => 't ' ,
8190
+ 'name ' => 'id ' ,
8191
+ 'len ' => 11 ,
8192
+ 'precision ' => 0 ,
8193
+ 'sqlite:decl_type ' => 'INTEGER ' ,
8194
+ ),
8195
+ $ column_info [0 ]
8196
+ );
8197
+ }
8173
8198
}
Original file line number Diff line number Diff line change @@ -1442,6 +1442,27 @@ private function execute_select_statement( WP_Parser_Node $node ): void {
1442
1442
// seems to erase type information for expressions in the SELECT clause.
1443
1443
$ this ->last_column_meta = array ();
1444
1444
for ( $ i = 0 ; $ i < $ stmt ->columnCount (); $ i ++ ) {
1445
+ /*
1446
+ * Workaround for PHP PDO SQLite bug (#79664) in PHP < 7.3.
1447
+ * See also: https://github.com/php/php-src/pull/5654
1448
+ */
1449
+ if ( PHP_VERSION_ID < 70300 ) {
1450
+ try {
1451
+ $ this ->last_column_meta [] = $ stmt ->getColumnMeta ( $ i );
1452
+ } catch ( Throwable $ e ) {
1453
+ $ this ->last_column_meta [] = array (
1454
+ 'native_type ' => 'null ' ,
1455
+ 'pdo_type ' => PDO ::PARAM_NULL ,
1456
+ 'flags ' => array (),
1457
+ 'table ' => '' ,
1458
+ 'name ' => '' ,
1459
+ 'len ' => -1 ,
1460
+ 'precision ' => 0 ,
1461
+ );
1462
+ }
1463
+ continue ;
1464
+ }
1465
+
1445
1466
$ this ->last_column_meta [] = $ stmt ->getColumnMeta ( $ i );
1446
1467
}
1447
1468
You can’t perform that action at this time.
0 commit comments