WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#53043 new defect (bug)

Upgrade to WP 5.7.1 fails if wp-config-sample.php not in home directory

Reported by: dlanced Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version:
Component: Upgrade/Install Keywords:
Focuses: Cc:

Description

One of my WP sites (that's set to auto-upgrade to new versions) just failed to upgrade to 5.7.1. I got the following error messages when I tried to upgrade from the dashboard:

<?text
Could not copy file.: wp-config-sample.php
Installation failed.

When I moved a copy of that file into the root and tried again, the upgrade worked.
This definitely isn't expected behaviour - and didn't occur for previous upgrades - and could cause confusion for others.
This instance is running on Ubuntu 20.04 in AWS EC2.
Thanks!

Change History (2)

#1 @dd32
5 months ago

Hi @dlanced,

This indicates that one these things happened differently than before:

  • The directory wasn't writable by WordPress
  • The server was experiencing a higher IO load causing failures
  • PHP thought it could write to the file, but failed to when actually doing it

The WordPress upgrade routines expect that full WordPress package is available - and yes, that includes the sample config file (although I totally understand why that's unexpected). As far as I know, this hasn't changed at all from previous releases.

(This next part is included for context for others working on the upgrade routines)

~100 (of 573 with this error code) sites that attempted to update to 5.7.1 ran into this error:

error_code: copy_failed__copy_dir_retry
error_data: wp-config-sample.php

While ~25 ran into this one:

error_code: files_not_writable
error_data: wp-config-sample.php

(out of ~10k with this error code - Looks like the majority of those ran into multiple files being unwritable)

It looks like you're probably one of the 100 based on the error message shared, that also means it's likely that WordPress has tried twice to write the file, and failed on both occasions.

Ignoring that WordPress has failed to update the file doesn't seem like a bad idea to me, BUT, it means that the file would also have to be excluded from checksum checking (although we already exclude .html/.txt files from that). I'm not sure I'd suggest ignoring a mismatching .php file in that, since it'd be a great place for an exploit to hide, but the file not existing is a minor issue rather than a show stopper.

#2 @dlanced
5 months ago

Thanks!

The directory wasn't writable by WordPress

In my case, the directory is writable (www-data). After all, WordPress successfully updated all the other files there.

The server was experiencing a higher IO load causing failures

I checked that. Loads of head room. And, again, the update succeeded just a few minutes later after I added a wp-config-sample.php file.

PHP thought it could write to the file, but failed to when actually doing it

I would guess that was the culprit in my case: since the wp-config-sample.php file wasn't there, that write failed.

Note: See TracTickets for help on using tickets.