Repository navigation
fix(migrations): read and write custom.ini through checked handles in the upload progress migration - #248
Open
mrrobot47 wants to merge 4 commits into
Conversation
… the upload progress migration The site's php container can swap custom.ini, conf.d or php/ in its config volume for a symlink, and the migration followed it: it read, rewrote, created or (on rollback) deleted custom.ini wherever the link pointed. It now uses site-command's checked helpers (get_container_file_contents() and put_container_file_contents()), and with an older site-command that lacks them it checks that custom.ini is a regular file and that no directory above it is a symlink. A missing custom.ini is no longer created, only warned about, as the site-command re-check migration does.
If putting the old content back failed too, the backup is the only copy, so it is kept and named in the warning; the fallback for an older site-command now reports a failed put-back.
…he size limit Rollback reads custom.ini back with the same limit, so content larger than it after the two lines are added is skipped with a warning instead of written.
With an older site-command, a failed write put the old content back by path without checking it again, so a symlink swapped in meanwhile was followed; the backup is kept and named in the warning instead.
There was a problem hiding this comment.
🟡 Changes recommended
Adding the setting can exceed the fallback's read limit, preventing rollback from restoring an otherwise accepted file.
1 open issue
What changed in this PR
This PR hardens the WordPress upload-progress migration against symlink redirection when accessing a site's custom.ini.
Changes:
- Uses checked file helpers when available, with path checks for older site-command versions.
- Stops creating missing configuration files and warns with manual instructions.
- Backs up the content already read and updates write-failure recovery and rollback handling.
| File | Description |
|---|---|
| migrations/container/20261021120000_site-type-wp_disable_wp_session_upload_progress.php | Adds guarded configuration access and revises backup and restoration logic. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
The v4.13.3 upload-progress migration (
20261021120000_site-type-wp_disable_wp_session_upload_progress) reads and writes each site'scustom.inithrough checked handles, so it can no longer be redirected outside the site's config volume.Why
The migration still runs on every upgrade from a version before v4.13.3.
custom.inilives in the site'sconfig_phpvolume, which the php container mounts at/usr/local/etc, so the container can replacecustom.ini,conf.dorphp/with a symlink. The migration checked onlycustom.iniitself (is_link()), then usedfile_get_contents()/file_put_contents()by path: with a symlinkedconf.dit read, rewrote or createdcustom.iniin whatever host directory the link pointed at, and its rollback deleted a file it had created there.How
get_container_file_contents()andput_container_file_contents()(fix(site): stop following symlinks from a site's php config volume in restore, update --php and migrations site-command#522): one checked handle, a regular file in the realconf.d, written in place, nothing created, and a file that changed since it was read is left alone.custom.iniis a regular file and that no directory above it is a symlink before each read and write. That closes a link that is already there, not one swapped in during the run.custom.iniis no longer created, only warned about with the manual fix, as site-command's re-check migration (fix(restore): keep session upload progress off after restoring an older backup site-command#520) does: PHP can't create a file safely in a directory the container can swap.custom.inithat the two lines would push over the 1 MB read limit is skipped with a warning, so rollback can always read back what was written.Testing
custom.inigets the Off line and rollback restores it; a missing one is warned about and not created; a symlinkedcustom.iniand a symlinkedconf.dare refused with a warning and the target directory stays byte for byte the same. The released migration fails the last three.develop, the migration re-run on a WordPress site whose php container swappedconf.dfor a symlink to a host directory: develop's migration writes the Off line into the host directory'scustom.ini; this branch's leaves it untouched and warns, with develop's site-command and with site-command#522; after the link is removed, the re-run adds the line at the top. Behat passes with this checkout and site-command#522.Release order
Works with any site-command; the race-safe path needs EasyEngine/site-command#522 (which needs #519 and #520), so ship them in the same release.