evolution / wordpress

Rapidly create, develop, & deploy WordPress across multiple environments.
MIT License
200 stars 18 forks source link

Invalid byte sequence in UTF-8 #155

Open jasoncomes opened 7 years ago

jasoncomes commented 7 years ago

When running bundle exec cap production evolve:down:files get this error:

DEBUG[1be24480]     2016/09/LeTourneau-University-768x196.webp is uptodate
DEBUG[1be24480]     2016/09/LeTourneau-University.jpg is uptodate
DEBUG[1be24480]     2016/09/LeTourneau-University.webp is uptodate
DEBUG[0262be27] Running /usr/bin/env [ -f /var/log/evolution/wordpress.log ] && [ $(stat -c %U /var/log/evolution/wordpress.log) == 'deploy' ] on production.affordablecolleges.com
DEBUG[0262be27] Command: [ -f /var/log/evolution/wordpress.log ] && [ $(stat -c %U /var/log/evolution/wordpress.log) == 'deploy' ]
DEBUG[0262be27] Finished in 0.201 seconds with exit status 0 (successful).
INFO[59ba9174] Running /usr/bin/env echo Mon\ Nov\ 21\ 13:09:30\ 2016\  jasoncomes@Jason-MacBook-Pro.local\ evolve:files:down\  Failure >> /var/log/evolution/wordpress.log on production.affordablecolleges.com
DEBUG[59ba9174] Command: /usr/bin/env echo Mon\ Nov\ 21\ 13:09:30\ 2016\    jasoncomes@Jason-MacBook-Pro.local\ evolve:files:down\  Failure >> /var/log/evolution/wordpress.log
INFO[59ba9174] Finished in 0.172 seconds with exit status 0 (successful).
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host production.affordablecolleges.com: invalid byte sequence in UTF-8
/Library/Ruby/Gems/2.0.0/gems/colorize-0.7.3/lib/colorize.rb:71:in `scan'
/Library/Ruby/Gems/2.0.0/gems/colorize-0.7.3/lib/colorize.rb:71:in `colorize'
(eval):4:in `green'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/formatters/pretty.rb:31:in `block in write_command'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/formatters/pretty.rb:30:in `each'

This is caused by the Marketing/Content team uploading files with invalid UTF8 names, breaking the possibility to pull down. Moving forward we'll be adding something along these lines to prevent this issue -> https://wpartisan.me/tutorials/rename-clean-wordpress-media-filenames. For the meantime is there a way to find the file names on the production server to be able to fix(find invalid UTF8 byte characters and rename command for files in the uploads directory) or something we can do on the server to prevent this error. Right now, its broken on affordablecolleges.com and onlinecolleges.net.

EvanK commented 7 years ago

This is a bug within capistrano's stack (something to do with ruby's string encoding, I never fully understood it myself).

In the meantime, you should be able to find the offending files like this:

find /var/www/example.com/production/master/current/web/wp-content/uploads/ -name '*' -print | grep -P '[^\x00-\x7f]'

Note: it took a lot of googling and trial/error to just get that command figured out...and this will find any non ascii chars, be they valid UTF8 or not