wp-cli / search-replace-command

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

Domain is not changed for added fonts #196

Open srueegger opened 1 month ago

srueegger commented 1 month ago

Bug Report

Describe the current, buggy behavior

The command “wp search-replace” does not work as expected. With WordPress 6.5 the Gutenberg Full-Site-Editor got the possibility to add fonts (as direct upload or as direct download from Google Fonts).

If you now change the URL of a WordPress installation with “wp search-replace”, the URL of your own fonts is not adjusted - which means that the font files cannot be loaded.

Describe how other contributors can replicate this bug

Describe what you would expect as the correct outcome

The domain of the fonts should also be changed via “wp search-replace”.

Let us know what environment you are running this on

OS: Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:19:05 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8112 arm64
Shell:  /bin/zsh
PHP binary: /Applications/MAMP/bin/php/php8.1.13/bin/php
PHP version:    8.1.13
php.ini used:   /Applications/MAMP/bin/php/php8.1.13/conf/php.ini
MySQL binary:   /Applications/MAMP/Library/bin//mysql
MySQL version:  mysql  Ver 14.14 Distrib 5.7.39, for osx11.0 (x86_64) using  EditLine wrapper
SQL modes:  
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:   /Users/srueegger/Sites/compresso.ch
WP-CLI packages dir:    
WP-CLI cache dir:   /Users/srueegger/.wp-cli/cache
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 2.10.0
swissspidy commented 1 month ago

What's the exact command that you are using? Have you tried the --precise flag?

swissspidy commented 1 month ago

FWIW I cannot reproduce this.

I just did wp search-replace wordpress-cevelop wordpress-develop wp_post* on my local wordpress-develop.local site and the font URLs were replaced as expected in the source code.

danielbachhuber commented 1 month ago

My guess is that the URLs are JSON encoded (related https://github.com/wp-cli/search-replace-command/issues/186)

srueegger commented 1 month ago

So the error is definitely reproducible for me. I have installed a standard Wordpress under the domain “domaina.dvl.to”. And uploaded the following fonts in the fullsite editor.

Then i set this font as the default for headings and texts.

Fonts: testfonts.zip

This works fine:

Bildschirmfoto 2024-05-24 um 22 24 55

Then I simply copied the DocumentRoot and database and let the domain “domainb.dvl.to” point to it.

Then I use “wp search-replace” to change the domains, the process is also executed:

Bildschirmfoto 2024-05-24 um 22 29 51

When opening the domain, you can see that the fonts I have uploaded do not work. It is interesting to note that the fonts that are predefined in the WordPress theme “twentytwentyfour” seem to work perfectly.

Browser Console:

Bildschirmfoto 2024-05-24 um 22 30 58

Source Code with wrong Domain:

Bildschirmfoto 2024-05-24 um 22 31 26
ernilambar commented 1 month ago

I can reproduce this issue and it is indeed related to encoded value. When fonts are uploaded, entry is created in posts table and post_content looks like this:

{"src":"http:\/\/foo.local\/wp-content\/uploads\/fonts\/SZc83FzrJKuqFbwMKk6EtUf57DtOmCc.woff2","fontWeight":"400","fontStyle":"normal","fontFamily":"\"Alex Brush\"","preview":"https:\/\/s.w.org\/images\/fonts\/17.7\/previews\/alex-brush\/alex-brush-400-normal.svg"}

When I try to generate sql after replacing the domain, eg:

wp search-replace 'http://foo.local' 'http://bar.local' --export=sample.sql

Then value shown above is not updated to new domain.