Skip to content

feat(php-compat): show the estimate and progress before a table-format check - #552

Merged
mrrobot47 merged 9 commits into
EasyEngine:developfrom
mrrobot47:feat/php-compat-estimate-first
Dec 2, 2026
Merged

mrrobot47 merged 9 commits into
EasyEngine:developfrom
mrrobot47:feat/php-compat-estimate-first

Conversation

@mrrobot47

@mrrobot47 mrrobot47 commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

A check of a large site can run for most of an hour with no output, which reads as a hung command. With the default table format, ee site php-compat now estimates how long the check will take before it starts, prints that, and shows the time elapsed while the check runs.

What users see

$ ee site php-compat example.com --php=8.4
Estimating how long the check of example.com for PHP 8.4 will take. This can take a minute or two.
It should take about 4 minutes (3 to 10): 14,552 PHP files, 80 MB, 14 components.
Checking example.com for PHP 8.4. To stop it, run: ee site php-compat example.com --cancel
Checking: 2m 18s elapsed of about 4 minutes (3 to 10)

Not safe to upgrade example.com to PHP 8.4: 26 errors in 4 components. 74 warnings. 14552 files checked.
...

On a terminal, the Checking: … elapsed line rewrites itself about once a second and is cleared before the result is printed. When stderr is not a terminal there is no live line, only the phase lines. The first check after the scanner image changes also prints "Getting the easyengine/compat-scanner image. This can take a few minutes." before the pull, for --estimate in table format too.

The estimate reuses the existing estimate container and parsing, and runs under the same site lock as the check, so no other check can start between the two. If the estimate fails (it times out, the container dies, or its output is invalid), one line says so and the check runs anyway; the estimate is advisory. When the estimate finds no code, that is the result, since the check lists the files the same way. A second check while the first is still estimating reports busy exactly as before.

Output channels and JSON

The phase and progress lines go to stderr; stdout holds only the result, as before. So | head, | grep, | tee and > file see the same table as before, while the terminal still shows progress. The progress lines are written with fwrite(), so a lost terminal doesn't stop a long check.

--format=json is unchanged: no estimate runs, stdout is the same single JSON document, stderr stays empty and the exit codes are the same. This was compared before and after on a WordPress site with about 14,500 PHP files and on a php site: the documents were identical apart from duration_s. --estimate output and --cancel are unchanged too.

--timeout still covers the scan only; the estimate before it isn't counted. ee.log gets one more line for the estimate, in the existing style (status and counts only).

Cancel and delete during the estimate

The estimate container carries the same labels as before, so ee site php-compat <site> --cancel and ee site delete stop it during the estimate phase as they stop the check: the run reports cancelled and no container is left. An estimate container that a timeout leaves running is removed before the check starts, and its label is kept until the removal worked, so cleanup() retries a removal that a signal or a cancel cut short. When --cancel and the stopped run's cleanup remove the same estimate container at once, Docker answers the second docker rm -f with "removal of container … is already in progress"; that now counts as removed, as "No such container" already did, instead of making --cancel report that it couldn't remove the container (this could also happen before with --estimate and --cancel).

Tests

Behat (features/php-compat.feature):

  • updated table scenarios read the phase lines from stderr and the result from stdout;
  • the JSON scenario asserts an empty stderr and no estimate in ee.log;
  • new scenarios cover:
    • an estimate that fails and one that times out, both falling through to the check;
    • --cancel and ee site delete during the estimate;
    • busy during the estimate;
    • --timeout in table format;
    • the no-code short-circuit;
    • the progress line on a terminal.

The suite's cleanup also removes leftover estimate containers by their label.

All php-compat scenarios pass on PHP 7.4 and 8.5 (main and wp lanes). The change was also run on a live host on real sites, including:

  • TTY and piped output;
  • a lost terminal;
  • Ctrl-C;
  • | head -1;
  • > file;
  • --debug;
  • the first image pull.

Summary by CodeRabbit

  • New Features
    • Table-format PHP compatibility checks now show an estimated duration before scanning, followed by elapsed-time progress while the scan runs. Progress appears in the terminal separately from results.
    • JSON-format checks run without a preliminary estimate.
  • Bug Fixes
    • If a duration estimate fails or times out, the scan proceeds. If no PHP code is found, the check ends without starting a scan.
    • Checks now clean up estimate containers when a site is deleted or a check is cancelled.

A check of a large site can run for most of an hour with no output, which reads as a hung command. With the default table format the command now runs the estimate first, under the same site lock, and prints how long the check should take before it starts. While the check runs, a terminal gets one self-updating line with the time elapsed against that estimate; it is cleared before the result. Piped output gets only the phase lines.

A failed estimate is reported in one line and the check runs anyway. When the estimate finds no code, that is the result, as the check would find the same. A --cancel or a site delete during the estimate stops the run as before, and an estimate container left by a timeout is removed before the check starts. --timeout still covers the scan only.

--format=json is unchanged: no estimate runs and stdout holds only the JSON document.
The table scenarios expect the estimate and check lines before the verdict. New scenarios cover a failed estimate that falls through to the check, --cancel during the estimate, and the progress line on a terminal. The JSON scenario asserts that no estimate runs and stdout holds only the document.
The STDOUT steps strip ANSI escape sequences, so the scenario could never see the line clearing it asserts. Piping the terminal output through cat -v keeps them visible.
…stimate

A paused estimate makes the client hit its time limit: the scenario checks that the estimate container is gone before the check runs and that the check still finishes. Deleting the site during the estimate makes the check report cancelled. The terminal scenario now checks ee's exit status and reads the saved output through cat -v in a separate step.
…e removal

Progress and phase lines now go to stderr, so stdout holds only the result again: `| head`, `| grep`, `| tee` and `> file` see the table as before, while the terminal still shows the progress; the self-updating line is shown when stderr is a terminal.

The first table check on a host now says it is getting the scanner image before the pull, which can take minutes.

The estimate container's label is kept until its removal worked, so a signal or a cancel that cuts the mid-run removal short leaves cleanup() able to retry it; this also covers plain --estimate runs.

Smaller: a cancelled estimate is no longer logged as a failed one, the progress line is cleared before the debug line that follows the scan, and an estimate of a site with no PHP files of its own isn't printed as "about 1 second".
…ng the estimate

The table scenarios read the progress lines from stderr and the result from the start of stdout again; the JSON scenario asserts an empty stderr. New checks: no check runs after the estimate finds no code, a second check during the estimate is busy before printing anything, and --timeout in the table format applies to the scan only. The suite's cleanup also removes estimate containers of its sites by their label, so a failed run can't leave a paused one for the next scenario.
A table-format --estimate also pulls the scanner image the first time, so it gets the same line before the pull. The line no longer claims the pull happens once per EasyEngine version: it also runs when a local image has to be pulled again.
…ing as gone

A --cancel during an estimate and the stopped run's own cleanup both remove the estimate container. Docker answers the second docker rm -f with "removal of container … is already in progress", which --cancel reported as "could not remove the estimate container". That answer now counts as removed, as "No such container" already did, both for --cancel and for the run's own cleanup.
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: PHP compatibility command

Layer / File(s) Summary
Estimate-first check flow
src/helper/Site_PHP_Compat.php, src/helper/class-ee-site.php, features/php-compat.feature, features/COVERAGE.md
Table-format checks run and log an estimate before scanning. JSON checks skip estimation, and a no-code estimate ends the check without starting a scan.
Terminal progress output
src/helper/Site_PHP_Compat.php, src/helper/class-ee-site.php, features/php-compat.feature
Terminal checks display elapsed-time progress and clear the progress line around Docker output, cleanup, and signal handling.
Estimate failure and lifecycle cleanup
src/helper/Site_PHP_Compat.php, features/bootstrap/FeatureContext.php, features/php-compat.feature, features/COVERAGE.md
Estimate failures and timeouts can proceed to a scan. Site deletion and cancellation remove estimate containers. Scenarios verify container and temporary-directory cleanup.

Possibly related PRs

  • EasyEngine/site-command#543: Adds ee site php-compat --cancel; this pull request extends cancellation handling to estimation and its container cleanup.
  • EasyEngine/site-command#539: Introduces the ee site php-compat command and its table format, estimate mode, timeout, and container cleanup.

Change: Feature

Merge Risk: Minimal · up to 026d6

Table-format php-compat checks now show an estimate and progress before scanning, while JSON output is unchanged. The one remaining edge case, a leftover estimate container after a failed removal, is bounded and accepted by the maintainers. No merge-blocking risk remains.

Finishing Touches

Generate unit tests (beta)

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

Warning

Some tools did not complete. Review the errors below.

PHPStan (2.3.5)

Composer install failed: dependency resolution error. Check composer.json and composer.lock for version constraints.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 73ba6903-be96-462b-a542-2524cfdef230
Commits

Reviewing files that changed from the base of the PR and between f5d2bd6 and 026d6ec.

Files selected for processing: 5

  • features/COVERAGE.md
  • features/bootstrap/FeatureContext.php
  • features/php-compat.feature
  • src/helper/Site_PHP_Compat.php
  • src/helper/class-ee-site.php

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

@mrrobot47
mrrobot47 merged commit 214ef84 into EasyEngine:develop Dec 2, 2026
23 checks passed
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