Repository navigation
Conversation
…e limit The "offload limit reached" flag was set by the upload check and cleared only when a bulk offload started, so the warning stayed after the account usage dropped (for example after duplicate sites were removed). It also silently stopped new uploads from offloading. - The daily sync stores the account's offload limit and clears the flag when the account is below it again. - The upload check stores the account limit with the flag, so the warning no longer shows the 50,000 default. - The upload check counts the images still to upload only while a bulk offload runs. The progress of a finished offload or of a rollback (which records how many images it moves back) no longer counts toward the limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes requested
The new limit guard ignores the pending images of a WP-CLI bulk offload. Fix that and the two type gaps in the new tests.
Validation details
- Files reviewed: 4/4 changed files.
- I ran the five new tests with
sandbox-phpunit-ab.shon PHP 8.3 and the WordPress 7.1.3 test library. HEAD reportedOK (5 tests, 11 assertions). - The base tree reported
Tests: 5, Assertions: 9, Failures: 4.Four new tests detect the change. - The security check found no new trust boundary. The stored values come from the account API through cron or admin-only paths.
- The SDK
getUsage()reads the sameoffloaded_imagesandoffload_limitfields as the daily sync.
Untested areas
test_daily_sync_without_usage_details_keeps_the_warningalso passes on the base tree. It guards only the branch where nothing changes.- The live account API response was not captured. The tests use a mocked response.
🤖 Automated review · run code-review-agent_6acb86aca88ff0.61986987.
🤖 Review agent — review posted ✅ on a9fcc18f · changes requested · 3 findings · 13 min
Run code-review-agent_6acb86aca88ff0.61986987 · trail
…limit The upload check counted the "remaining" images only while the dashboard offload status was on, and `wp optimole media move_to_optimole` never sets that status, so a CLI offload no longer stopped before the limit. record_process_meta() now stores which transfer the progress belongs to, and the check counts it for offloads only, from the dashboard or WP-CLI. Progress recorded before this change has no transfer: it counts only while a dashboard offload runs, so stale rollback progress on existing sites stops tripping the limit. Also types the new tests, and moves the media tests away from the place where two other open PRs add theirs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes requested
The WP-CLI fix works, but progress from a stopped offload now always counts. Fix that and add two native types.
Validation details
- Files reviewed: 5/5 changed files. The new checks cover the 4 files changed since the prior review.
- The new and changed tests ran on HEAD and on a base tree with
sandbox-phpunit-ab.sh, PHP 8.3. HEAD passed 9 tests. The base tree reported 2 errors and 6 failures, and only the sync test without usage details passed. - The focused limit test passed on HEAD:
cd /repo; set -o pipefail; phpunit --do-not-cache-result --filter 'Test_Media::test_only_a_pending_offload_counts_toward…printedOK (4 tests, 10 assertions)(run R3) - The security check comes from run code-review-agent_6acb86aca88ff0.61986987 and was not rerun. The new
actionkey comes only from internal callers.
Untested areas
- The WP-CLI command cannot run under PHPUnit. Its path was traced in the source only.
- The live account API response was not captured.
🤖 Automated review · run code-review-agent_6acb9afce22107.31181124.
🤖 Review agent — review posted ✅ on 3d41c762 · changes requested · 3 findings · 15 min
Run code-review-agent_6acb9afce22107.31181124 · trail
"remaining" stays in the progress after an offload finished, was cancelled or stopped at the limit, so it kept counting toward the limit of later uploads: after the daily sync cleared the warning, the next upload set it again. It now counts only while the offload is going: a dashboard offload while its status is on, and one from WP-CLI while the command runs. The command marks its progress as a foreground run and clears the mark when it ends (shutdown function, so also on an error exit). A rollback never counts. Also adds native types to record_process_meta() and the new helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…terrupted The shutdown function that clears the mark does not run on Ctrl+C or SIGTERM, so an interrupted command kept counting its pending images toward the offload limit. The mark is now the time of the run's last activity: each offloaded image refreshes it, and it counts only while it is younger than the lifetime of a transfer step (10 minutes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…LI offload The mark of a WP-CLI offload expires when the command stops refreshing it. A later offloaded image refreshed the mark even after it had expired, which made the stale progress count again. The mark is now refreshed only while it is still alive and cleared otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approved
The PR passes. The three earlier findings are fixed, and the new commit adds no new problem.
Validation details
- Files reviewed: 5/5 changed files. New checks cover the 3 files changed since 3d41c76.
sandbox-phpunit-ab.shran the new and changed tests on PHP 8.3 againstpr-base. HEAD reportedOK (18 tests, 42 assertions). The base tree reported 13 assertion failures and 4 missing-method errors.- The same script ran against 3d41c76. HEAD reported
OK (11 tests, 27 assertions). The base tree failed the ended-offload, interrupted-run and refresh cases. - The security check from run code-review-agent_6acb86aca88ff0.61986987 was not rerun. The new commit changes no trust boundary.
Untested areas
- The WP-CLI command was not executed. Its path was traced in the source only.
- The provider row
'WP-CLI offload that is running'attests/test-media.php:789takestime()when the suite is built. The row fails when more than 600 seconds pass before it runs. The full-suite timing in CI was not measured. - The live account API response was not captured.
🤖 Automated review · run code-review-agent_6acbbc3beacce9.38528771.
🤖 Review agent — review posted ✅ on 0906a79f · approved · 0 findings · 17 min
Run code-review-agent_6acbbc3beacce9.38528771 · trail
…built Data providers run when the suite is built. The 'running WP-CLI offload' row took time() there, so it would fail once more than ten minutes pass before the test runs. The provider now gives the age of the mark and the test dates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes requested
The new commit fixes the time-dependent provider rows. Update the provider's @return shape for the new fourth element.
Validation details
- Files reviewed: 1/1 file changed since 0906a79. The other files were reviewed in run code-review-agent_6acbbc3beacce9.38528771 and not rerun.
sandbox-phpunit-ab.shranTest_Media::test_only_a_running_offload_counts_toward_the_offload_limiton PHP 8.3 againstpr-base.- HEAD reported
OK (9 tests, 21 assertions). - The base tree reported
Tests: 9, Assertions: 15, Failures: 9., including both changed WP-CLI rows.
Untested areas
- The WP-CLI command was not executed. Its path was traced in the source only.
- The live account API response was not captured.
🤖 Automated review · run code-review-agent_6acbc7523d71f4.50596281.
🤖 Review agent — review posted ✅ on 3dddf4af · changes requested · 1 finding · 4 min
Run code-review-agent_6acbc7523d71f4.50596281 · trail
…vider Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approved
The PR passes. The new commit declares the optional fourth provider element, which fixes the last open finding.
Validation details
- Files reviewed: 1/1 file changed since 3dddf4a. The other files were reviewed in earlier runs.
- The provider docblock at
tests/test-media.php:780now matches its rows and the?int $mark_ageparameter. cd /repo; php -l tests/test-media.phpprintedNo syntax errors detected in tests/test-media.php(run R1)- Run code-review-agent_6acbc7523d71f4.50596281 ran the provider test on PHP 8.3, not rerun. HEAD reported
OK (9 tests, 21 assertions). The base tree reported nine failures.
Untested areas
- The WP-CLI command was not executed. Its path was traced in the source only.
- The live account API response was not captured.
🤖 Automated review · run code-review-agent_6acbd2b632da57.59390431.
🤖 Review agent — review posted ✅ on a34edda3 · approved · 0 findings · 1 min
Run code-review-agent_6acbd2b632da57.59390431 · trail
Related issue: #1118
The "offload limit reached" warning stayed after the account usage dropped, with the 50,000 default as the limit. The flag behind it was only cleared when a bulk offload started, and while it was set new uploads silently stopped being offloaded. The daily sync now reconciles it with the account usage.
What changed
Optml_Admin::daily_sync()— the account details already includeoffload_limitandoffloaded_images. The sync stores the limit, and clears the flag when the account is below it.Optml_Media_Offload::generate_image_meta())optml_process_meta"remaining") only while that offload is going. "remaining" stays in the progress after a run, and a rollback records the images it moves back in the same place, so a single upload could set the flag although the account was far below the limit.record_process_meta()) — also stores which transfer it belongs to (offload_imagesorrollback_images) and whether it runs in the foreground (WP-CLI). The newget_pending_offload_count()uses that:offloading_statusis on (the plugin switches it off on finish, cancel and limit stop);end_foreground_process_meta(), from a shutdown function, so also on an error exit), and it counts only while it is younger than 10 minutes. An interrupted command (Ctrl+C) therefore stops counting on its own, and a later upload does not bring an expired mark back;Note
If the account really is at its limit, the next upload sets the flag again (preflight or upload exception), so clearing it daily cannot hide a real limit for long.
Tests
tests/test-offload-limit-sync.php(new): the daily sync clears the warning and stores the limit when usage is below it, keeps it at the limit, and changes nothing without usage details.tests/test-media.php:<=instead of<in the sync, limit not stored by the sync or the check, a rollback counting, an ended offload counting, a running WP-CLI or dashboard offload not counting, the mark never cleared, never recorded, never refreshed or never going stale, an expired mark being refreshed, and a dashboard offload getting the mark. Each fails a test.QA
On a connected site, trigger the warning (or set the
offload_limit_reachedsetting toenabledwith WP-CLI:wp eval '( new Optml_Settings() )->update( "offload_limit_reached", "enabled" );').Run the daily sync:
wp cron event run optml_daily_sync.Expect: in
WP Admin → Optimole → Settings → Image Storage, the limit warning is gone, and a new upload is offloaded.Verification (head
a34edda3)tests/test-media.phpandtests/test-offload-limit-sync.php, each run alonephpcs,phpstan(build-only include errors excluded locally; CI builds assets first)a9fcc18f) and 2 (3d41c762): no findings. Round 3 (e2b4f490): the WP-CLI mark stayed after Ctrl+C, because a shutdown function does not run then (fixed: the mark now goes stale by itself). Round 4 (c16bb44c): a later upload refreshed a mark that had already expired (fixed). Rounds 5 (0906a79f), 6 (3dddf4af) and 7 (a34edda3): no findings.a9fcc18f): changes requested, a WP-CLI offload no longer counted its pending images, and test types (fixed). Round 2 (3d41c762): changes requested, an offload that already ended still counted, and two native types (fixed). Round 3 (0906a79f): approved, with a note that one provider row dated the WP-CLI mark when the suite is built and would fail on a run slower than 10 minutes (fixed in3dddf4af, test only). Round 4 (3dddf4af): changes requested, the return type of that provider (fixed ina34edda3). Round 5 (a34edda3): approved.a34edda3Not proven
🤖 Generated with Claude Code