• Resolved giggles420

    (@gigglesslut420)


    To programmatically purge specific URLs, I’ve been using the method described in the plugin FAQ > Advanced:
    do_action("swcfpc_purge_cache", array("https://example.com/some-page/", "https://example.com/other-page/"));

    After today’s update to 5.0.5, this no longer works. It worked reliably until today.
    From the debug log, I see six lines like this one any time I try to use my purge php file:
    [2024-10-29 09:50:27] [cloudflare::purge_cache_urls_async_cache] Response for request 0: {"success":false,"errors":[{"code":9106,"message":"Missing X-Auth-Key, X-Auth-Email or Authorization headers"}]}

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Ionut Neagu

    (@ionutn)

    Thanks for reporting, would look into it.

    Plugin Support Andrei Baicus

    (@baicusandrei)

    Hey @gigglesslut420,

    Could you provide more details as to where exactly are you hooking this particular piece of code in the codebase?

    Thank you!

    Thread Starter giggles420

    (@gigglesslut420)

    I use a php file like this, which I normally load in a browser when I want to purge the URLs:

    <?php
    if ( ! headers_sent() ) {
    header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
    header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
    }

    define( 'DOING_CRON', true );

    if ( ! defined( 'ABSPATH' ) ) {
    /** Set up WordPress environment */
    require_once DIR . '/wp-load.php';
    }
    do_action("swcfpc_purge_cache", array("https://example.com/111/", "https://example.com/222/", "https://example.com/333/"));

    I searched through the previous version of the plugin for “purge_cache_urls_async” as it was mentioned in the debug log, and found it in libs/cloudflare.class.php. I did not find purge_cache_urls_async in the current version of cloudflare.class.php but similar code is in src/Services/Cloudflare_Client.php in the current version of the plugin.

    • This reply was modified 3 weeks, 5 days ago by giggles420.
    Plugin Support Andrei Baicus

    (@baicusandrei)

    Hey @gigglesslut420,

    Thank you for taking the time & providing the use-case! We’re going to fix this in an upcoming release.

    Meanwhile, you can fix it on your end in the src/Services/Cloudflare_Client.php file, on line 386, by passing the true argument to the get_api_auth_args() method like below:

    $args = $this->get_api_auth_args( true );

    Please let me know if this fixes your issue!

    All the best!

    Thread Starter giggles420

    (@gigglesslut420)

    Thank you.
    That worked.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.