Hi James, thank you, I’m happy you like FDP.
I can imagine two possible causes for this issue:
- When you save the page, for some reason FDP prevents a certain plugin from running, and that plugin is needed to clear the page cache. You mentioned this is handled by an MU-plugin. Normally, that shouldn’t be the case, but check if the MU-plugin calls code written in a standard plugin. Is there a plugin that can be associated with that MU-plugin?
- FDP, for some reason, triggers a fatal error that stops the process.
I think cause #2 is more likely. For example, you may have a WooCommerce add-on that runs during the saving process while WooCommerce itself is disabled. If that add-on calls a WooCommerce function without first checking if it exists, it would trigger a fatal error before StackCache starts clearing the page cache.
This is just a supposition. To understand better what’s going on, I suggest you:
- Enable debugging in
wp-config.php. If you need more information, read how to enable debugging in WordPress.
- Save the page.
- Check the file
wp-content/debug.log and let me know if you see any errors.
I hope this helps.
Jose
@james-feaver
Thread Starter
James
(@james-feaver)
Hi Jose,
Thanks for the quick response.
1. The MU-plugin code is fairly brief it doesn’t seem to call a standard plugin:
<?php
/**
- Plugin Name: StackCache
- Plugin URI: http://cache.stackcp.com/
- Description: Wrapper to include the Stack Cache Plugin Library
- Author: Stack CP
*/
// If this file is called directly, abort.
if ( ! defined( “WPINC” ) ) die;
// Load and include
$file_suffix = “/wp-admin/includes/file.php”;
$count = 0;
while ( true ) {
$path = str_repeat(“../”, $count) . $file_suffix;
$full_path = plugin_dir_path(FILE) . $path;
if ( file_exists($full_path) ) {
require_once($full_path);
define( ‘PLUGIN_DIR’, plugin_dir_path( FILE ) );
break;
}
if ( $count++ > 5 ) {
print(“Failed to find ‘wp-admin/includes/file.php'”);
exit(1);
}
}
// Run
require “/usr/share/php/wp-stack-cache.php”;
$wpsc = new WPStackCache();
2. I did the debugging and the only messages are to do with translations loading too early for two other, unrelated plugins.
Sorry, but I don’t think my above responses will help. As a test, I created a new page (not product) – that is visible in an incognito browser window, but if I edit it and save it, the changes are NOT reflected in the incognito window after refreshing the page. This shows the problem is not WooCommerce related but more core WP / caching.
Thanks,
James
You are welcome!
The code of the mu-plugin that you shared tries to locate WordPress’s wp-admin/includes/file.php by going up one directory at a time, and when it finds it, it includes it.
Then it defines the plugins directory, and it loads the external library wp-stack-cache.php
Look at this line of code:
require “/usr/share/php/wp-stack-cache.php
It looks like this method doesn’t respect the standard folder structure of a normal WordPress installation, and it requires a file outside of WordPress. I’m not surprised you have issues.
Anyway, I suggest you check the content of the filw wp-stack-cache.php. Do you see any code that calls a standard plugin? Is it possible to share the content of that file?
Thread Starter
James
(@james-feaver)
Hi Jose,
I contacted my host and their response doesn’t help:
What they’ve said here is true, i.e. we locate the file.php file within WordPress by stepping up a directory at a time, and we then require the stack-cache plugin from the shared server your package is on. Unfortunately, however, we are not able to provide a copy of the stack-cache file or its contents. Are there perhaps alternatives to the Freesoul Deactivate Plugin that do the same thing, but don’t conflict with the cache?
I think we’ve hit a brick wall at their end. Can we do anything at this end?
Thanks,
James
Hi James,
Why aren’t they able to provide a copy of the stack-cache file?
You could mention that Freesoul Deactivate Plugins is open source, just like the rest of the WordPress ecosystem. Either they check the FDP code and solve the issue, or they provide a copy of their file so we can take a look.
Right now, they are running PHP code that you cannot see. This is not acceptable. That file could contain any code, and it is executed on your website, where sensitive information may be stored. What they are doing is against the law. I think you should insist on being allowed to review that code.
Unfortunately, just know there is some code that runs is not enough to understand what is going on.
Best regards
Jose
If they don’t help, you can still get the code of that file.
Make a backup of the mu-plugin. Then change the content of that file with:
<?php
/**
- Plugin Name: StackCache
- Plugin URI: http://cache.stackcp.com/
- Description: Wrapper to include the Stack Cache Plugin Library
- Author: Stack CP
*/
// If this file is called directly, abort.
if ( ! defined( “WPINC” ) ) die;
// Load and include
$file_suffix = “/wp-admin/includes/file.php”;
$count = 0;
while ( true ) {
$path = str_repeat(“../”, $count) . $file_suffix;
$full_path = plugin_dir_path(FILE) . $path;
if ( file_exists($full_path) ) {
error_log( file_get_contents( $full_path ) );
require_once($full_path);
define( ‘PLUGIN_DIR’, plugin_dir_path( FILE ) );
break;
}
if ( $count++ > 5 ) {
print(“Failed to find ‘wp-admin/includes/file.php’”);
exit(1);
}
}
// Run
require “/usr/share/php/wp-stack-cache.php”;
$wpsc = new WPStackCache();
as you can see, I’ve added the line
error_log( file_get_contents( $full_path ) );
Enable the debug after changing the mu-plugin. Visit a page, or save it. You will find the code of that file inside wp-content/debug.log
Then restore the original mu-plugin.
Better you only add the line
error_log( file_get_contents( $full_path ) );
If you copy/paste the entire code, you may trigger fatal errors due to copy/paste issues.