Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#42963 closed enhancement (fixed)

Improve deletion of $_old_files during upgrades

Reported by: joemcgill's profile joemcgill Owned by: dd32's profile dd32
Milestone: 4.9.2 Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords: has-patch
Focuses: Cc:

Description

While testing upgrades for #42720, it occurred to me that if the upgrade process failed to delete old files, we were potentially leaving rather large files behind to clutter up the file system. To avoid this scenario, we could attempt to empty the contents of old files if they still exist after unsuccessfully deleting them during an upgrade routine.

Attachments (1)

42963.diff (663 bytes) - added by joemcgill 7 years ago.

Download all attachments as: .zip

Change History (18)

@joemcgill
7 years ago

#1 @joemcgill
7 years ago

  • Keywords has-patch added

42963.diff writes an empty string to files that still exist after an unsuccessful deletion attempt.

#2 @dd32
7 years ago

is_file( $old_file ) won't work as expected here, as $to is not always a full filesystem path.

Personally I think we can skip the is_file() check, as delete() should return correctly.
In the worst case scenario, where delete() returns incorrectly, it'll get removed on the next run hopefully.

This seems like a good addition overall. I think we should also consider back-porting the change to all autoupdate branches so that all updates are consistent.

#3 @dd32
7 years ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In 42433:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Fixes #42963 for trunk.

#4 @dd32
7 years ago

In 42434:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42433] to the 4.9 branch.
Fixes #42963 for 4.9.

#5 @dd32
7 years ago

  • Milestone changed from 5.0 to 4.9.2

This seems like a good addition overall. I think we should also consider back-porting the change to all autoupdate branches so that all updates are consistent.

Going to do exactly this. In most cases this shouldn't ever actually be needed, but as we ship this file with all autoupdates we might as well have it be consistent between every version.

#6 @dd32
7 years ago

In 42466:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 4.8 branch.
Fixes #42963 for 4.8.

#7 @dd32
7 years ago

In 42467:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 4.7 branch.
Fixes #42963 for 4.7.

#8 @dd32
7 years ago

In 42468:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 4.6 branch.
Fixes #42963 for 4.6.

#9 @dd32
7 years ago

In 42469:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 4.5 branch.
Fixes #42963 for 4.5.

#10 @dd32
7 years ago

In 42470:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 4.4 branch.
Fixes #42963 for 4.4.

#11 @dd32
7 years ago

In 42471:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 4.3 branch.
Fixes #42963 for 4.3.

#12 @dd32
7 years ago

In 42472:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 4.2 branch.
Fixes #42963 for 4.2.

#13 @dd32
7 years ago

In 42473:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 4.1 branch.
Fixes #42963 for 4.1.

#14 @dd32
7 years ago

In 42474:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 4.0 branch.
Fixes #42963 for 4.0.

#15 @dd32
7 years ago

In 42475:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 3.9 branch.
Fixes #42963 for 3.9.

#16 @dd32
7 years ago

In 42476:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 3.8 branch.
Fixes #42963 for 3.8.

#17 @dd32
7 years ago

In 42477:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 3.7 branch.
Fixes #42963 for 3.7.

Note: See TracTickets for help on using tickets.