Skip to content

Stored LCP image ID as an integer - #1213

Merged
pirate-bot merged 1 commit into
developmentfrom
bugfix/1202
Oct 31, 2026
Merged

pirate-bot merged 1 commit into
developmentfrom
bugfix/1202

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

Fixed Optimole’s LCP image detection by storing the frontend profiler’s LCP image ID as an integer using absint() and casting the ID to an integer during comparison. This restores correct strict comparisons so Optimole can apply fetchpriority="high" and avoid lazy-loading the LCP image when appropriate. The lookup also uses isset() to prevent missing IDs from being treated as 0, while the comparison-time cast keeps existing cached profiles with string IDs working immediately without waiting for their seven-day TTL to expire.

Closes #1202

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@pirate-bot

Copy link
Copy Markdown
Collaborator

Plugin build for f0d986d is ready 🛎️!

@girishpanchal30 girishpanchal30 changed the title Sttored LCP image ID as an integer Stored LCP image ID as an integer Oct 29, 2026

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

The LCP image ID is now stored and compared as an integer, and the new tests cover the REST path and legacy string IDs.

Validation details
  • Files reviewed: 3/3 changed files.
  • PHPUnit 9.6.22 on PHP 8.3.36 at HEAD: cd /repo; set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-cache-result --filter 'Test_Lazyload_Viewport::' 2>&1… printed OK (18 tests, 49 assertions) (run R3) for Test_Lazyload_Viewport.
  • PHPUnit at HEAD: cd /repo; grep -n "^class" tests/test-page-profiler-shape.php; C=$(grep -o '^class [A-Za-z_]*' tests/test-page-profiler-… printed OK (27 tests, 53 assertions) (run R4) for Test_Page_Profiler_Shape.
  • By source, both new tests fail on pr-base code. A helper run against pr-base agreed, but it printed no run record.
  • Source trace: the frontend sends an integer or null. A zero ID is stored with type bg, so it never matches.
  • Security: the endpoint keeps its hash, time and origin checks. The ID is only compared, never printed raw.
Untested areas
  • The end-to-end suite does not reach this behavior. Real page rendering was not checked in a browser.

🤖 Automated review · run code-review-agent_6ae31ef1400830.69474530.


🤖 Review agent — review posted ✅ on f0d986d7 · approved · 0 findings · 18 min

Run code-review-agent_6ae31ef1400830.69474530 · trail

@pirate-bot
pirate-bot merged commit dbf4223 into development Oct 31, 2026
14 checks passed
@pirate-bot
pirate-bot deleted the bugfix/1202 branch October 31, 2026 13:01
@pirate-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 4.2.18 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@pirate-bot pirate-bot added the released Indicate that an issue has been resolved and released in a particular version of the product. label Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Indicate that an issue has been resolved and released in a particular version of the product.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants