OSDN Git Service

Fix search replace reserved column name issues.
authorAlex Ciobica <alex.ciobica@gmail.com>
Tue, 6 Aug 2013 11:33:04 +0000 (14:33 +0300)
committerAlex Ciobica <alex.ciobica@gmail.com>
Tue, 6 Aug 2013 11:33:04 +0000 (14:33 +0300)
php/commands/search-replace.php

index 4185598..c1e4b00 100644 (file)
@@ -101,10 +101,12 @@ class Search_Replace_Command extends WP_CLI_Command {
                // We don't want to have to generate thousands of rows when running the test suite
                $chunk_size = getenv( 'BEHAT_RUN' ) ? 10 : 1000;
 
+               $fields = array( $primary_key, $col );
+               $fields = array_map( function ($v) { return "`$v`"; }, $fields );
                $args = array(
                        'table' => $table,
-                       'fields' => array( $primary_key, $col ),
-                       'where' => $col . ' LIKE "%' . like_escape( esc_sql( $old ) ) . '%"',
+                       'fields' => $fields,
+                       'where' => "`$col`" . ' LIKE "%' . like_escape( esc_sql( $old ) ) . '%"',
                        'chunk_size' => $chunk_size
                );