Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"wp-cli/db-command": "^1.3 || ^2",
"wp-cli/entity-command": "^1.3 || ^2",
"wp-cli/extension-command": "^1.2 || ^2",
"wp-cli/wp-cli-tests": "^3.1"
"wp-cli/wp-cli-tests": "^4"
},
"config": {
"process-timeout": 7200,
Expand Down
4 changes: 3 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<!-- Can't be helped as WP itself uses these functions for the data being adjusted. -->
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize"/>
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize"/>
<!-- Allow $new as an argument to mitigate code churn -->
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.newFound" />
</rule>

<!--
Expand Down Expand Up @@ -68,7 +70,7 @@
Related: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1623 -->
<rule ref="WordPress.NamingConventions.ValidVariableName">
<properties>
<property name="customPropertiesWhitelist" type="array">
<property name="allowed_custom_properties" type="array">
<element value="Key"/>
<element value="Field"/>
<element value="Type"/>
Expand Down
2 changes: 1 addition & 1 deletion search-replace-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
return;
}

$wpcli_search_replace_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php';
$wpcli_search_replace_autoloader = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $wpcli_search_replace_autoloader ) ) {
require_once $wpcli_search_replace_autoloader;
}
Expand Down
19 changes: 9 additions & 10 deletions src/Search_Replace_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function __invoke( $args, $assoc_args ) {
}
}
$export_insert_size = Utils\get_flag_value( $assoc_args, 'export_insert_size', 50 );
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- See the code, this is deliberate.
// phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- See the code, this is deliberate.
if ( (int) $export_insert_size == $export_insert_size && $export_insert_size > 0 ) {
$this->export_insert_size = $export_insert_size;
}
Expand Down Expand Up @@ -473,7 +473,7 @@ private function php_export_table( $table, $old, $new ) {
if ( $value && ! in_array( $col, $primary_keys, true ) && ! in_array( $col, $this->skip_columns, true ) ) {
$new_value = $replacer->run( $value );
if ( $new_value !== $value ) {
$col_counts[ $col ]++;
++$col_counts[ $col ];
$value = $new_value;
}
}
Expand All @@ -491,7 +491,7 @@ private function php_export_table( $table, $old, $new ) {
$table_report[] = array( $table, $col, $col_count, 'PHP' );
}
if ( $col_count ) {
$total_cols++;
++$total_cols;
$total_rows += $col_count;
}
}
Expand Down Expand Up @@ -590,7 +590,7 @@ static function ( $key ) {
$replacer->clear_log_data();
}

$count++;
++$count;
if ( ! $this->dry_run ) {
$update_where = array();
foreach ( (array) $keys as $k => $v ) {
Expand Down Expand Up @@ -682,10 +682,10 @@ private function write_sql_row_fields( $table, $rows ) {

// Add new insert statement if needed. Before this we close the previous with semicolon and write statement to sql-file.
// "Statement break" is needed:
// 1. When the loop is running every nth time (where n is insert statement size, $export_index_size). Remainder is zero also on first round, so it have to be excluded.
// $index % $export_insert_size == 0 && $index > 0
// 2. Or when the loop is running last time
// $index == $count
// 1. When the loop is running every nth time (where n is insert statement size, $export_index_size). Remainder is zero also on first round, so it have to be excluded.
// $index % $export_insert_size == 0 && $index > 0
// 2. Or when the loop is running last time
// $index == $count
if ( ( 0 === $index % $export_insert_size && $index > 0 ) || $index === $count ) {
$sql .= ";\n";

Expand All @@ -710,7 +710,7 @@ private function write_sql_row_fields( $table, $rows ) {
$sql .= ",\n";
}

$index++;
++$index;
}
}

Expand Down Expand Up @@ -1043,5 +1043,4 @@ private function log_write( $col, $keys, $table, $old_bits, $new_bits ) {

fwrite( $this->log_handle, "{$table_column_id_log}\n{$old_log}\n{$new_log}\n" );
}

}