Even if WordPress is a very mature script, sometimes file issues can appear. In this post, we will discuss missing or altered WordPress files’ issues.
How to fix missing/altered WordPress files:
1. First of all, check the WordPress version for the specific installation. In our example, the WordPress version is 5.4
wp core version
root@www [/home/max12/public_html/wordpress]# wp core version --allow-root
5.4
root@www [/home/max12/public_html/wordpress]#
2. Now we will check if we have the correct files for the specific WordPress version (5.4)
wp core verify-checksums --version=5.4
root@www [/home/max12/public_html/wordpress]# wp core verify-checksums --version=5.4 --allow-root
Warning: File doesn't verify against checksum: wp-cron.php
Warning: File doesn't verify against checksum: wp-admin/includes/ajax-actions.php
Warning: File doesn't exist: wp-admin/includes/bookmark.php
Warning: File should not exist: wp-includes/js/unfile90
Error: WordPress installation doesn't verify against checksums.
root@www [/home/max12/public_html/wordpress]#
As you can see the tool will list altered files, files that don’t exist, and files that should not be in the WordPress installation.
You can manually check and correct the listed files or you can use another wp-cli command as in the example below. With this command, the WordPress files will be downloaded and existing files will be overwritten.
wp core download --version=5.4 --force
root@www [/home/max12/public_html/wordpress]# wp core download --version=5.4 --force --allow-root
Downloading WordPress 5.4 (en_US)...
md5 hash verified: b4ffcc17cbe6a6546fba4112d55e8ba5
Success: WordPress downloaded.
root@www [/home/max12/public_html/wordpress]#
Verifying again the installation, we get:
root@www [/home/max12/public_html/wordpress]# wp core verify-checksums --version=5.3 --allow-root
Warning: File should not exist: wp-includes/js/unfile90
Success: WordPress installation verifies against checksums.
root@www [/home/max12/public_html/wordpress]#
Notice that the wp-cli tool will not delete any files that are not part of the default WordPress installation. You will need to delete them manually.
We worked as root, so it’s possible that some files have root permission. to fix this, run a command like:
root@www [/home/max12/public_html/wordpress]# chown -R max12:max12 .
You can also execute wp-cli commands as a specific user. Just use the su user at the beginning.