• James

    (@james-feaver)


    Hi,

    Firstly fantastic plugin. Getting “greedy” plugins off pages they have no business going near is really welcome from a performance perspective.

    I have become aware of an issue on my site since using your plugin. If I edit a WooCommerce product page and save it, the changes appear to me as admin where the cache is not being used, but do not appear to standard site visitors. To make the changes visible I currently have to purge the cache for the whole site (from their Admin page, not via their plugin). My host’s caching plugin is a must use plugin (MUP), StackCache, which does work well. If I save edits to a page, post or product, it should purge the cache for just that page but it is not working in this way at present.

    I tried deactivating your plugin and the result was as expected, edits were visible to users immediately, so the cache was cleared for that page. MUPs are not listed in the FDP “Plugin Manager”. Is there a way I can resolve this issue please?

    Thanks,

    James

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jose Mortellaro

    (@giuse)

    Hi James, thank you, I’m happy you like FDP.
    I can imagine two possible causes for this issue:

    1. 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?
    2. 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:

    1. Enable debugging in wp-config.php. If you need more information, read how to enable debugging in WordPress.
    2. Save the page.
    3. 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

    Plugin Author Jose Mortellaro

    (@giuse)

    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

    Plugin Author Jose Mortellaro

    (@giuse)

    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

    Plugin Author Jose Mortellaro

    (@giuse)

    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.

    Plugin Author Jose Mortellaro

    (@giuse)

    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.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘FDP & Must Use Plugins?’ is closed to new replies.