Fix problems with placing object-cache.php
drop-in
#672
+65
−116
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.
Summary
Fixes #630
Relevant technical choices
object-cache.php
drop-in, the plugin would attempt to rename it toobject-cache-plst-orig.php
, then place its ownobject-cache.php
file which would then alsorequire_once
the renamed original drop-in. This worked correctly in principle, however several popular plugins regularly check the file contents of theobject-cache.php
file to check whether their drop-in is present rather than checking for e.g. a constant that the file sets. Due to that behavior, in practice the approach the Performance Lab plugin has taken led to several incompatibilities. This PR fixes that problem going forward by removing that approach. Now the Performance Lab drop-in will only be placed if no conflicting drop-in is present.object-cache-plst-orig.php
file is maintained for backward compatibility: For example, for sites for which that approach has been working as expected, it will need to be ensured that the deactivation routine not only deletes the Performance Labobject-cache.php
drop-in, but also restores the original drop-in (i.e. renamesobject-cache-plst-orig.php
back toobject-cache.php
).function_exists()
check around the one function that the Performance Lab drop-in defines to prevent any fatal error e.g. in case another drop-in likeadvanced-cache.php
loads theobject-cache.php
drop-in extra early.Testing instructions
Without existing drop-in
wp-content/object-cache.php
file in your setup.wp-content/object-cache.php
file now exists and has the same content as theserver-timing/object-cache.copy.php
file within the plugin.wp-content/object-cache.php
file no longer exists.With drop-in already present
server-timing/object-cache.copy.php
file towp-content/object-cache.php
.wp-content/object-cache.php
file still exists and has the same content as theserver-timing/object-cache.copy.php
file within the plugin.wp-content/object-cache.php
file no longer exists.With conflicting drop-in present
object-cache.php
drop-in from a plugin like e.g. W3 Total Cache) inwp-content/object-cache.php
.wp-content/object-cache.php
file still exists and has the same content as before. The plugin's own file should not replace it.wp-content/object-cache.php
file still exists (as it is not our own, so we shouldn't remove it).With old code (our drop-in plus renamed other drop-in)
server-timing/object-cache.copy.php
file towp-content/object-cache.php
.object-cache.php
drop-in from a plugin like e.g. W3 Total Cache) inwp-content/object-cache-plst-orig.php
.wp-content/object-cache.php
andwp-content/object-cache-plst-orig.php
files still exist and have the same content as before.wp-content/object-cache.php
file now has the content that previously was in thewp-content/object-cache-plst-orig.php
file, and that thewp-content/object-cache-plst-orig.php
file is now removed (as in that case we need to restore the other drop-in in its original location, which was something the plugin used to do, so this is critical for backward compatibility with older PL plugin versions).Checklist
[Focus]
orInfrastructure
label.[Type]
label.no milestone
label.