Skip to content

Commit ada8f31

Browse files
Copilotswissspidy
andcommitted
Fix CI failure: restore primary-key rows in export report
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 0191dc8 commit ada8f31

1 file changed

Lines changed: 7 additions & 26 deletions

File tree

src/Search_Replace_Command.php

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -603,28 +603,8 @@ private function php_export_table( $table, $old, $new ) {
603603
'chunk_size' => $chunk_size,
604604
);
605605

606-
// Determine which columns are actually eligible for search/replace and reporting.
607-
$report_columns = array();
608-
foreach ( $all_columns as $col ) {
609-
// Respect --include-columns if provided.
610-
if ( ! empty( $this->include_columns )
611-
&& ! in_array( $col, $this->include_columns, true )
612-
&& ! in_array( $table . '.' . $col, $this->include_columns, true ) ) {
613-
continue;
614-
}
615-
616-
// Skip primary key and explicitly skipped columns.
617-
if ( in_array( $col, $primary_keys, true )
618-
|| in_array( $col, $this->skip_columns, true )
619-
|| in_array( $table . '.' . $col, $this->skip_columns, true ) ) {
620-
continue;
621-
}
622-
623-
$report_columns[] = $col;
624-
}
625-
626606
$replacer = new SearchReplacer( $old, $new, $this->recurse_objects, $this->regex, $this->regex_flags, $this->regex_delimiter, false, $this->regex_limit );
627-
$col_counts = array_fill_keys( $report_columns, 0 );
607+
$col_counts = array_fill_keys( $all_columns, 0 );
628608
if ( $this->verbose && 'table' === $this->format ) {
629609
$this->start_time = microtime( true );
630610
WP_CLI::log( sprintf( 'Checking: %s', $table ) );
@@ -635,11 +615,12 @@ private function php_export_table( $table, $old, $new ) {
635615
$row_fields = array();
636616
foreach ( $all_columns as $col ) {
637617
$value = $row->$col;
638-
if ( ! empty( $this->include_columns ) && ! in_array( $col, $this->include_columns, true ) && ! in_array( $table . '.' . $col, $this->include_columns, true ) ) {
639-
$row_fields[ $col ] = $value;
640-
continue;
641-
}
642-
if ( $value && ! in_array( $col, $primary_keys, true ) && ! in_array( $col, $this->skip_columns, true ) && ! in_array( $table . '.' . $col, $this->skip_columns, true ) ) {
618+
if ( $value
619+
&& ! in_array( $col, $primary_keys, true )
620+
&& ! in_array( $col, $this->skip_columns, true )
621+
&& ! in_array( $table . '.' . $col, $this->skip_columns, true )
622+
&& ( empty( $this->include_columns ) || in_array( $col, $this->include_columns, true ) || in_array( $table . '.' . $col, $this->include_columns, true ) )
623+
) {
643624
$new_value = $replacer->run( $value );
644625
if ( $new_value !== $value ) {
645626
++$col_counts[ $col ];

0 commit comments

Comments
 (0)