Hi 😄
So I'm moving a client site today and it seems there was a mysql error when moving a table because I had created custom views with hyphen characters in table-names.
WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-de' at line 1 for query DESCRIBE products-de made by include('phar:///usr/local/bin/wp/php/boot-phar.php'), include('phar:///usr/local/bin/wp/php/wp-cli.php'), WP_CLI\Runner->start, WP_CLI\Runner->_run_command, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}, call_user_func, Search_Replace_Command->__invoke, Search_Replace_Command->php_export_table, Search_Replace_Command::get_columns
WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-de' at line 1 for query SELECT COUNT(*) FROM products-de made by include('phar:///usr/local/bin/wp/php/boot-phar.php'), include('phar:///usr/local/bin/wp/php/wp-cli.php'), WP_CLI\Runner->start, WP_CLI\Runner->_run_command, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}, call_user_func, Search_Replace_Command->__invoke, Search_Replace_Command->php_export_table, WP_CLI\Iterators\Query->valid, WP_CLI\Iterators\Query->load_items_from_db, WP_CLI\Iterators\Query->adjust_offset_for_shrinking_result_set
WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM products-de LIMIT 1000 OFFSET 0' at line 1 for query SELECT FROM products-de LIMIT 1000 OFFSET 0 made by include('phar:///usr/local/bin/wp/php/boot-phar.php'), include('phar:///usr/local/bin/wp/php/wp-cli.php'), WP_CLI\Runner->start, WP_CLI\Runner->_run_command, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}, call_user_func, Search_Replace_Command->__invoke, Search_Replace_Command->php_export_table, WP_CLI\Iterators\Query->valid, WP_CLI\Iterators\Query->load_items_from_db
Error: Database error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM products-de LIMIT 1000 OFFSET 0' at line 1
I Actually run wp-cli in a script, but the output just has more errors if I don't run in the script (due to some abysmally written "premium" plugins no doubt)
#!/bin/bash
SITEDIR='/usr/share/nginx/vhosts/somesite.com'
mv "${SITEDIR}/public/wp-content/plugins" "${SITEDIR}/public/wp-content/plugins-old"
wp search-replace https://www.somesite.com https://site-old.somesite.com --all-tables --precise --recurse-objects --export=site-old-`date +"%Y-%m-%d-%H%M"`.sql --path="${SITEDIR}/public"
mv "${SITEDIR}/public/wp-content/plugins-old" "${SITEDIR}/public/wp-content/plugins"
So the fix for me was to rename my custom views, which works, but maybe something to look at in the code?
It's absolutely a niche problem, it's no big if the code cannot be changed as I now know to add checking for hyphens in table and view names, but if you are open to a PR, I'm open to giving it a go 😉
Hi 😄
So I'm moving a client site today and it seems there was a mysql error when moving a table because I had created custom views with hyphen characters in table-names.
I Actually run wp-cli in a script, but the output just has more errors if I don't run in the script (due to some abysmally written "premium" plugins no doubt)
So the fix for me was to rename my custom views, which works, but maybe something to look at in the code?
It's absolutely a niche problem, it's no big if the code cannot be changed as I now know to add checking for hyphens in table and view names, but if you are open to a PR, I'm open to giving it a go 😉