• Hello,

    I updated my install on WPEngine to PHP 8 and now I’m getting this error:

    PHP Fatal error: Uncaught TypeError: strcasecmp(): Argument #1 ($string1) must be of type string, array given in /nas/content/live/swiftmodders/wp-content/plugins/wp-cloudflare-page-cache/libs/cloudflare.class.php:1295\\nStack trace:\\n#0 /nas/content/live/swiftmodders/wp-content/plugins/wp-cloudflare-page-cache/libs/cloudflare.class.php(1295): strcasecmp(Array, '{resp:x-wp-cf-s...')\\n#1 /nas/content/live/swiftmodders/wp-content/plugins/wp-cloudflare-page-cache/libs/cloudflare.class.php(1578): SWCFPC_Cloudflare->page_cache_test('https://swiftmo...', '')\\n#2 /nas/content/live/swiftmodders/wp-includes/class-wp-hook.php(308): SWCFPC_Cloudflare->ajax_test_page_cache('')\\n#3 /nas/content/live/swiftmodders/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)\\n#4 /nas/content/live/swiftmodders/wp-includes/plugin.php(517): WP_Hook->do_action(Array)\\n#5 /nas/content/live/swiftmodders/wp-admin/admin-ajax.php(188): do_action('wp_ajax_swcfpc_...')\\n#6 {main}\\n thrown in /nas/content/live/swiftmodders/wp-content/plugins/wp-cloudflare-page-cache/libs/cloudflare.class.php on line 1295, referer: https://swiftmodders.com/wp-admin/options-general.php?page=wp-cloudflare-super-page-cache-index

    Any ideas?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    Hi @swiftmodders,
    That is so wired as I am not seeing that issue on any websites where I am running this plugin. I’m using this plugin on many websites running PHP 8 and 8.1 none have this Fatal Error. Are you using the latest version of the plugin?

    Thread Starter John Lewis

    (@swiftmodders)

    Hi Saumya,

    Yes, I am using the latest version of all plugins on my system. I use EDD to sell my products, and people cannot purchase correctly. I could deduce that the problem was Super Cache for Cloudflare by testing on my staging environment in WPEngine. Since Cloudflare is only enabled in my production environment, I deactivated the addon instinctively to test. I noticed orders went through fine in test mode without Supercache enabled on PHP 8. However, it did not work in my production environment, and I had to downgrade to 7.4 to allow it to work again.

    I wish I could set up an environment for you to test this yourself, but I do not see how. I cannot upgrade to PHP 8 on my production environment as it will cause that same issue again. My staging environment does not have Cloudflare enabled, but I suppose I could set up a Cloudflare account for my staging environment.

    Let me know what would be helpful to you. I would like to upgrade to PHP 8 in the near future. 🙂

    Thanks,
    John

    Plugin Contributor iSaumya

    (@isaumya)

    Hi,
    a couple of questions,
    1. Is this issue happening all the time after you upgrade to PHP 8 or only when you are Clicking on the “Test Cache” button?

    Cause looking at the code: https://plugins.trac.wordpress.org/browser/wp-cloudflare-page-cache/trunk/libs/cloudflare.class.php#L1295

    the $headers['Cache-Control'] should always be a string but for some reason in your website, it is returning an Array, I don’t understand why…

    Can you share your website URL so that I can look at the response header?
    Also if somehow you can this following line:

    $this->objects['logs']->add_log('test_log', "$headers['Cache-Control'] -> ". print_r( $headers['Cache-Control'], true) );

    Just above the if block? Also, make sure you have enabled the log mode. Then update to PHP 8 and check the logs to see what Array data it is receiving…

    You are having this issue because in your case that code is returning an Array where it should always be a string.

    Thread Starter John Lewis

    (@swiftmodders)

    Hi Saumya,

    This issue would happen each time I clicked on “Test Cache,” yes. It only happens on PHP 8; it does not happen on PHP 7.4.

    I’ll have to see if there is a way for me to test this because I cannot do this on my production install. It breaks EDD, and people cannot purchase from my site.

    Thanks,
    John

    Plugin Contributor iSaumya

    (@isaumya)

    This issue would happen each time I clicked on “Test Cache,” yes. It only happens on PHP 8; it does not happen on PHP 7.4.

    – OK. So the plugin is working perfectly but the Test Cache is throwing the error. But then again if you don’t use the Test Cache button you should not see this error. I told you why the error is coming. So, unless you dig more to see why that field is returning an Array when it is supposed to be a string, we won’t know for sure.

    For now, you can refrain from using the Test Cache button and instead check the response header directly in the Network tab of the Chrome Dev Tools.

    Thread Starter John Lewis

    (@swiftmodders)

    Hi Saumya,

    Thanks for your help thus far. EDD developers just told me they have an issue with PHP 8, which may be related to that. Once they have a fix, I’ll test to see if that was contributing to the issue with Super Cache.

    Thanks,
    John

    Plugin Contributor iSaumya

    (@isaumya)

    OK. Keep me posted.

    Thread Starter John Lewis

    (@swiftmodders)

    Hi Saumya,

    EDD developers have confessed to me that EDD is not fully compatible with PHP 8. More than likely, my issues stem from that. Until EDD is fully compatible, I’ll have to stay on PHP 7.4.

    Thanks,
    John

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Error on PHP 8’ is closed to new replies.