Skip to content

Migrate Presslabs hosting compatibility into ThirdParty (part of #8768) - #8780

Open
remyperona wants to merge 1 commit into
developfrom
enhancement/8768-presslabs
Open

Migrate Presslabs hosting compatibility into ThirdParty (part of #8768)#8780
remyperona wants to merge 1 commit into
developfrom
enhancement/8768-presslabs

Conversation

@remyperona

Copy link
Copy Markdown
Contributor

🤖 AI-generated — created by an automated pipeline. Review before acting on this.

Part of #8768

Description

Migrate the Presslabs hosting-compatibility file (inc/3rd-party/hosting/presslabs.php) into the WP_Rocket\ThirdParty\Hostings service-provider architecture, as one of six per-host PRs splitting #8768 for easier review and testing. Detected through HostResolverHostSubscriberFactory (single-match). Also fixes a long-standing clean_home() bug.

Type of change

  • New feature (non-breaking change which adds functionality).
  • Bug fix (non-breaking change which fixes an issue).
  • Enhancement (non-breaking change which improves an existing functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as before).
  • Sub-task of Migrate hosting compatibility files into ThirdParty service provider #8768
  • Chore
  • Release

Detailed scenario

What / Why

Presslabs becomes a Subscriber_Interface class detected via defined('PL_INSTANCE_REF') + class_exists('\Presslabs\Cache\CacheHandler') + advanced-cache.php present. The constructor keeps the idempotent require_once advanced-cache.php (safe: the class is already loaded per the detection guard). The clean_home() dead-guard bug is fixed so the homepage is actually purged.

What was tested

Hostings unit group passes in the wp-env container (composer test-unit -- --group Hostings), including the corrected clean_home() regression test.

How to test

  • On a Presslabs site, trigger after_rocket_clean_home and confirm the homepage URL is invalidated (previously a no-op).
  • Confirm the Presslabs CDN/partial-purge/cache-file hooks fire at the same priorities as before.
  • On any other site, confirm Presslabs is not instantiated and no presslabs require remains in 3rd-party.php.

Affected Features & Quality Assurance Scope

  • Hosting compatibility (inc/ThirdParty/Hostings/), HostResolver, HostSubscriberFactory, inc/3rd-party/3rd-party.php.
  • Presslabs cache-handler integration, homepage/post purge, CDN CNAMEs, partial-purge-hook removal.

Technical description

Documentation

New inc/ThirdParty/Hostings/Presslabs.php; a presslabs branch in HostResolver; a presslabs case in HostSubscriberFactory; presslabs require removed and legacy file deleted. Bug fix: clean_home() no longer guards on undefined $post/$permalink. Regression test updated to assert the homepage is invalidated.

New dependencies

None.

Risks

Low–medium — a mechanical port plus one behavior-restoring bug fix, both covered by unit tests; Presslabs.php is ported from the validated combined branch.

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.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

Unticked items justification

Covered by the Hostings unit suite (run in the wp-env container) plus PHPStan and PHPCS; behavior parity (and the intentional clean_home fix) verified against the deleted procedural file.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

Port inc/3rd-party/hosting/presslabs.php into a container-registered
WP_Rocket\ThirdParty\Hostings\Presslabs subscriber, detected via
HostResolver (PL_INSTANCE_REF + \Presslabs\Cache\CacheHandler +
advanced-cache.php present) and built by HostSubscriberFactory. The
constructor keeps the (idempotent) require_once of advanced-cache.php.

Also fixes the long-standing clean_home() bug (it guarded on undefined
$post/$permalink instead of its $root/$lang parameters and so never
purged the homepage). Regression test asserts the corrected behavior.

Part of #8768. One of six per-host PRs splitting the hosting-compat
migration for easier review and testing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Aug 28, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 1 medium

Results:
1 new issue

Category Results
UnusedCode 1 medium

View in Codacy

🟢 Metrics 11 complexity

Metric Results
Complexity 11

View in Codacy

🟢 Coverage 100.00% diff coverage

Metric Results
Coverage variation Report missing for 9bdce291
Diff coverage 100.00% diff coverage (50.00%)

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (9bdce29) Report Missing Report Missing Report Missing
Head commit (38cadfe) 47687 22504 47.19%

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 (#8780) 42 42 100.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%

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.

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant