wp-cli / search-replace-command

Searches/replaces strings in the database.
MIT License
57 stars 45 forks source link

skipping entries in the wp_posts table #133

Closed spencerdcarlson closed 10 months ago

spencerdcarlson commented 4 years ago

Describe the current, buggy behavior search-replace is not properly updating values in the wp_posts table.

Steps to reproduce

wp search-replace 'from.com' 'to.com' \
  --recurse-objects \
  --skip-columns=guid \
  --skip-tables=wp_users \
  --path=$WP_PATHP_PATH

Here is the first occurrence of from.com

INSERT INTO `wp_posts` VALUES (1,1,'2020-02-15 00:42:07','2020-02-15 00:42:07','<!-- wp:paragraph -->\n<p>Welcome to WordPress    . This is your first post. Edit or delete it, then start writing!</p>\n<!-- /wp:paragraph -->','Hello world!','','trash','open    ','open','','hello-world__trashed','','','2020-02-17 15:54:14','2020-02-17 15:54:14','',0,'http://from.com/?p=1    ',0,'post','',1),(2,1,'2020-02-15 00:42:07','2020-02-15 00:42:07'...

Here is the entire export of the wp_posts table after I ran the wp search-replace command search-error.sql.zip

Describe what you would expect as the correct outcome I would expect all occurrences of the string to be replaced

Let us know what environment you are running this on OS

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:    18.04
Codename:   bionic

MySQL

mysql --version
mysql  Ver 14.14 Distrib 5.7.29, for Linux (x86_64) using  EditLine wrapper

WP CLI

OS: Linux 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 x86_64
Shell:  /bin/bash
PHP binary: /usr/bin/php7.2
PHP version:    7.2.24-0ubuntu0.18.04.3
php.ini used:   /etc/php/7.2/cli/php.ini
WP-CLI root dir:    phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:  phar://wp-cli.phar/vendor
WP_CLI phar path:   /home/sc
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0
figureone commented 4 years ago

I think you said --skip-columns=guid, but that's the column with from.com. So it's doing what you told it to. :)

swissspidy commented 10 months ago

I think you said --skip-columns=guid, but that's the column with from.com. So it's doing what you told it to. :)

Looking at the example above I tend to agree. Closing for now but please feel free to reopen if I missed something.