Font Face & Font Library: Load PHP files only if the main class does not exist. #54103
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Prevents Font Face and Font Library PHP files from loading into memory if each main class already exists in memory (i.e. meaning already in WordPress Core).
Why?
As a fail-safe to avoid
Fatal error: Cannot declare class
.In all PRs after Font Face was merged into Core, the PHP 7.0 multisite tests fail:
This change is being made to unblock all PRs.
A follow-up review will happen to investigate why only PHP 7.0 multisite tests fail with this fatal error, while all other PHP versions do not fail. From that follow-up review, recommendations can be made for if this approach should be adopted instead of class_exists guard at the top of each class file.
How?
In the
load.php
file, it wraps each group of files to only load if its main class does not exist in memory.Testing Instructions
The PHP 7.0 tests should pass.