Skip to content

fix(migration): drop the unused custom.ini backup when the write is refused - #124

Open
mrrobot47 wants to merge 1 commit into
EasyEngine:developfrom
mrrobot47:fix/upload-progress-migration-unused-backup
Open

mrrobot47 wants to merge 1 commit into
EasyEngine:developfrom
mrrobot47:fix/upload-progress-migration-unused-backup

Conversation

@mrrobot47

@mrrobot47 mrrobot47 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Same change as in site-type-wp, for PHP sites. The session upload progress migration backs up custom.ini before writing it. When the write is then refused and the file is left as it was (for example because custom.ini is a hard link), the warning pointed to the backup as "the original custom.ini" as if the file had been changed, and the backup dir under /opt/easyengine/.backup/session-upload-progress-php-<date>/ was left behind after up() and down().

Now only a write that failed part-way keeps the backup and names it in the warning, as before. Any other refusal is reported as "Skipped disabling session.upload_progress for : ", like the other skips, and its backup is removed, along with the migration's backup dir once it is empty. A failed backup is cleaned up the same way.

This migration already shipped in v4.13.3, and container migrations run once per host, so the change only reaches hosts that upgrade from 4.13.2 or older. A host already on 4.13.3 or 4.14.0 where a write was refused keeps that backup dir; it holds only an unchanged copy of the site's custom.ini and can be deleted by hand.

Tested with new PHPUnit tests on PHP 7.4 and 8.5: a hard-linked custom.ini leaves no backup and no backup path in the warning, and a run with one refused site and one changed site keeps only the changed site's backup until down() restores it. Both tests fail before the change. A write that fails part-way (file size limit) still keeps its backup, names it and leaves custom.ini with its original content, before and after. An end-to-end run of the migration differs from before only in the hard-linked site's warning and in leaving no backup dir.

Summary by CodeRabbit

  • Bug Fixes
    • Incomplete backups are now cleaned up when backup creation fails or a write is refused for reasons other than a write error.
    • Backups are retained, and their location is reported, when a write error prevents the operation from completing.
    • Cleanup stops if an error occurs while removing backup files, helping prevent further cleanup attempts after a failure.

…efused

disable_php_session_upload_progress backs up custom.ini before it writes the file. When site-command then refuses the write without touching the file (a hard link, a symlink swapped in, a changed file, an older site-command), the warning still said "The original custom.ini is <backup>", as if the file had been changed, and the backup and its dir stayed after up() and down().

Only a failed write ("could not write ...") can leave the file changed, so only that case keeps the backup and names it. Any other refusal now warns "Skipped disabling session.upload_progress for <site>: <reason>", like the other skips, and removes the site's backup dir, and the migration's backup dir once it is empty. A backup that fails part-way is cleaned up the same way.
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Backup cleanup

Layer / File(s) Summary
Backup cleanup behavior
migrations/container/20261021120100_site-type-php_disable_php_session_upload_progress.php
update_site removes the site backup when backup creation fails or when a write error does not start with could not write. Errors with that prefix retain the backup. The new remove_backup helper logs site backup removal errors and, after successful removal, attempts to remove the shared backup root.

Possibly related PRs

  • EasyEngine/site-type-php#121: It changes the checked read and write behavior in the same migration and handles refusal cases that this PR addresses.

Change: Bug fix

Merge Risk: Minimal · up to 7758e

The change removes the unused custom.ini backup when the migration declines to write, and keeps the backup when a write fails part-way. No concrete merge-blocking defect was established. Its safety depends on how an external site-command helper words its write-failure messages, which could not be checked here.

Security architecture risk: Low · up to 7758e

Cleanup is narrowly scoped, and recognized partial-write failures still retain their backups. However, other writer exceptions now cause the recovery copy to be deleted. The writer’s complete failure contract could not be checked, leaving a bounded uncertainty about recovery after an unrecognized post-write failure.

Retained concerns

  • Low · reliability · inferred: Backup disposal now relies on an external writer’s exception-message prefix. An unrecognized exception following mutation would delete the migration’s recovery copy while leaving the site outside automatic restoration. The complete producer contract is unavailable, so this is an inferred recovery-contract risk, not an observed data-loss failure.
Security review details

Security Blast Radius

  • inferred — The changed authority concerns host-side backup removal for PHP sites processed by this migration. A writer-contract mismatch could affect recovery for multiple sites on that host, but the inspected change adds no cross-host, network, credential or container-execution authority.

Trust Boundaries and Controls

  • observed — The existing file-access boundary remains delegated to site-command’s checked reader and writer. Missing utility functions cause exceptions rather than unchecked fallback access, and the update passes expected content to the writer. The migration documents that the site’s container can replace paths in its configuration volume; the dependency’s enforcement could not be independently inspected.

Hardening Proposals

  • proposed — Use an explicit writer outcome or typed exception to distinguish confirmed pre-mutation refusals from failures that may have changed the file, preserving the backup for unknown outcomes. This would make the recovery decision independent of diagnostic wording.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aa4dc545-4fed-4b60-bc51-9b9b861601fb
Commits

Reviewing files that changed from the base of the PR and between 88cd58f and 7758e98.

Files selected for processing: 1

  • migrations/container/20261021120100_site-type-php_disable_php_session_upload_progress.php

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant