Skip to content

Closes #6795 Clean LCP when site logo is changed#8080

Open
remyperona wants to merge 2 commits intodevelopfrom
enhancement/6795-lcp-logo
Open

Closes #6795 Clean LCP when site logo is changed#8080
remyperona wants to merge 2 commits intodevelopfrom
enhancement/6795-lcp-logo

Conversation

@remyperona
Copy link
Contributor

@remyperona remyperona commented Feb 20, 2026

Description

Fixes #6795

Type of change

  • Enhancement (non-breaking change which improves an existing functionality).

Detailed scenario

What was tested

Changed the site logo in a theme using the block editor

How to test

Changing the site logo in the customizer or in the block editor should trigger a cleanup of the LCP raws in the database.

Affected Features & Quality Assurance Scope

Critical images on site logo change

Technical description

Documentation

This PR addresses issue #6795 by implementing functionality to clean LCP (Largest Contentful Paint) data when the site logo is changed. The implementation hooks into WordPress's pre_set_theme_mod_custom_logo filter to detect logo changes and clears performance hints optimization tables accordingly.

Changes:

  • Added a new method clean_on_logo_change to the PerformanceHints Admin Controller that truncates performance hints tables when the logo value changes
  • Registered the pre_set_theme_mod_custom_logo filter hook in the PerformanceHints Admin Subscriber to trigger the cleanup
  • Added unit tests to verify the logo change detection and truncation behavior

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses issue #6795 by implementing functionality to clean LCP (Largest Contentful Paint) data when the site logo is changed. The implementation hooks into WordPress's pre_set_theme_mod_custom_logo filter to detect logo changes and clears performance hints optimization tables accordingly.

Changes:

  • Added a new method clean_on_logo_change to the PerformanceHints Admin Controller that truncates performance hints tables when the logo value changes
  • Registered the pre_set_theme_mod_custom_logo filter hook in the PerformanceHints Admin Subscriber to trigger the cleanup
  • Added unit tests to verify the logo change detection and truncation behavior

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
inc/Engine/Common/PerformanceHints/Admin/Controller.php Added clean_on_logo_change method that compares new and old logo values and truncates tables if they differ
inc/Engine/Common/PerformanceHints/Admin/Subscriber.php Registered pre_set_theme_mod_custom_logo filter hook and added subscriber method to delegate to controller
tests/Unit/inc/Engine/Common/PerformanceHints/Admin/Controller/CleanOnLogoChangeTest.php Unit test verifying truncation is called only when logo value changes
tests/Fixtures/inc/Engine/Common/PerformanceHints/Admin/Controller/CleanOnLogoChangeTest.php Test fixtures with scenarios for unchanged and changed logo values

@codacy-production
Copy link

codacy-production bot commented Feb 20, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 8e934451 75.00% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (8e93445) Report Missing Report Missing Report Missing
Head commit (3adf63e) 42229 19164 45.38%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#8080) 8 6 75.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@remyperona remyperona marked this pull request as ready for review March 3, 2026 15:40
@remyperona remyperona requested a review from a team March 3, 2026 15:41
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.

Clear Critical Images on site logo change on pages using it as LCP

3 participants