Fix problems with placing object-cache.php drop-in
#672
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.phpdrop-in, the plugin would attempt to rename it toobject-cache-plst-orig.php, then place its ownobject-cache.phpfile which would then alsorequire_oncethe renamed original drop-in. This worked correctly in principle, however several popular plugins regularly check the file contents of theobject-cache.phpfile 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.phpfile 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.phpdrop-in, but also restores the original drop-in (i.e. renamesobject-cache-plst-orig.phpback 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.phploads theobject-cache.phpdrop-in extra early.Testing instructions
Without existing drop-in
wp-content/object-cache.phpfile in your setup.wp-content/object-cache.phpfile now exists and has the same content as theserver-timing/object-cache.copy.phpfile within the plugin.wp-content/object-cache.phpfile no longer exists.With drop-in already present
server-timing/object-cache.copy.phpfile towp-content/object-cache.php.wp-content/object-cache.phpfile still exists and has the same content as theserver-timing/object-cache.copy.phpfile within the plugin.wp-content/object-cache.phpfile no longer exists.With conflicting drop-in present
object-cache.phpdrop-in from a plugin like e.g. W3 Total Cache) inwp-content/object-cache.php.wp-content/object-cache.phpfile still exists and has the same content as before. The plugin's own file should not replace it.wp-content/object-cache.phpfile 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.phpfile towp-content/object-cache.php.object-cache.phpdrop-in from a plugin like e.g. W3 Total Cache) inwp-content/object-cache-plst-orig.php.wp-content/object-cache.phpandwp-content/object-cache-plst-orig.phpfiles still exist and have the same content as before.wp-content/object-cache.phpfile now has the content that previously was in thewp-content/object-cache-plst-orig.phpfile, and that thewp-content/object-cache-plst-orig.phpfile 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]orInfrastructurelabel.[Type]label.no milestonelabel.