Skip to content

Commit e1d6e78

Browse files
Copilotswissspidy
andauthored
Fix code review: remove redundant cast, handle NULL as 'NULL' in query output
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 6414ec5 commit e1d6e78

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/DB_Command.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,13 +2554,23 @@ protected function wpdb_query( $query, $assoc_args = [] ) {
25542554

25552555
if ( $result instanceof mysqli_result ) {
25562556
$fields = $result->fetch_fields();
2557-
$headers = $fields ? array_column( (array) $fields, 'name' ) : [];
2557+
$headers = $fields ? array_column( $fields, 'name' ) : [];
25582558
if ( ! $skip_column_names && ! empty( $headers ) ) {
25592559
WP_CLI::line( implode( "\t", $headers ) );
25602560
}
25612561
$all_rows = $result->fetch_all( MYSQLI_NUM );
25622562
foreach ( $all_rows as $row ) {
2563-
WP_CLI::line( implode( "\t", array_map( 'strval', $row ) ) );
2563+
WP_CLI::line(
2564+
implode(
2565+
"\t",
2566+
array_map(
2567+
static function ( $v ) {
2568+
return null === $v ? 'NULL' : (string) $v;
2569+
},
2570+
$row
2571+
)
2572+
)
2573+
);
25642574
}
25652575
$result->free();
25662576
}

0 commit comments

Comments
 (0)