OSDN Git Service

search-replace: move primary key check
authorscribu <mail@scribu.net>
Sat, 8 Jun 2013 13:49:38 +0000 (16:49 +0300)
committerscribu <mail@scribu.net>
Sat, 8 Jun 2013 13:58:30 +0000 (16:58 +0300)
php/commands/search-replace.php

index 56e740f..e7d3fae 100644 (file)
@@ -31,6 +31,14 @@ class Search_Replace_Command extends WP_CLI_Command {
 
                foreach ( $tables as $table ) {
                        list( $primary_key, $columns ) = self::get_columns( $table );
+
+                       // since we'll be updating one row at a time,
+                       // we need a primary key to identify the row
+                       if ( null === $primary_key ) {
+                               $report[] = array( $table, '', 'skipped' );
+                               continue;
+                       }
+
                        foreach ( $columns as $col ) {
                                if ( in_array( $col, $skip_columns ) )
                                        continue;
@@ -81,9 +89,6 @@ class Search_Replace_Command extends WP_CLI_Command {
                        'chunk_size' => $chunk_size
                );
 
-               if ( $primary_key===null )
-                       return "skipped";
-
                $it = new \WP_CLI\Iterators\Table( $args );
 
                $count = 0;