• Hello!

    We are seeing a PHP warning on the front and backend of our site:

    Warning: foreach() argument must be of type array|object, null given in [..]/wp-content/plugins/real-cookie-banner/inc/settings/Cookie.php on line 353

    Image: https://imgur.com/acJCoUS

    I’m suspecting the webhoster enabled PHP warnings, as these only appeared after calling them. But as this is a managed WordPress instance, I don’t have access to these settings. I might be wrong, though. Do you have any idea why this message is showing?

    • PHP: 8.0.23
    • WordPress: 6.0.2
    • Contact Form 7 Version 5.6.3
    • Contact Form 7 Image Captcha Version 3.2.6
    • Elementor Version 3.7.7
    • Events Widgets For Elementor And The Events Calendar Version 1.6
    • Limit Login Attempts Reloaded Version 2.25.5
    • OMGF Version 5.3.9
    • Premium Addons for Elementor Version 4.9.34
    • Real Cookie Banner (Free) Version 3.1.6
    • The Events Calendar Version 6.0.1.1
    • UpdraftPlus – Backup/Restore Version 1.22.23
    • W3 Total Cache Version 2.2.4
    • WebP Express Version 0.25.5
    • Thanks,
      Stefan

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter TryAllTheThings

    (@roots84)

    For clarification:

    The warning is shown twice on all frontend pages when the Cookie Banner is enabled. It is shown twice on the Cookie Banner Dashboard and more than 200 times when activating / deactivating a plugin on the WordPress plugins page. The is no difference in the messages.

    Plugin Contributor Matthias Günter

    (@mguenter)

    Hey @roots84 !

    It looks like Real Cookie Banner could not be initialized correctly after activation and could not create the default services and service groups. What happens if you reset RCB in Cookies > Settings > “Reset all”?

    Thread Starter TryAllTheThings

    (@roots84)

    Hey @mguenter!

    Thanks for the reply. Resetting everything seems to work. The error messages are gone, and I can access all menus within Real cookie Banner.
    I even found a way to reproduce the issue. When I re-import my backed up configuration, everything seems to work out fine (although the import doesn’t work without modifying the export) but as soon as I visit the tab for statistics cookies (which only includes Google Analytics) the issue is back, and I can’t open most menus / tabs within Real Cookie Banner.

    Issue 1: The export (or the underlying issue I’m having) doesn’t create a valid JSON-file that I can re-import right after resetting. (Error: Invalid parameter json)
    Issue 2: The export includes the PHP warnings at the very top:

    <br />
    <b>Warning</b>:  foreach() argument must be of type array|object, null given in <b>[...]/htdocs/wordpress/wp-content/plugins/real-cookie-banner/inc/settings/Cookie.php</b> on line <b>353</b><br />
    <br />
    <b>Warning</b>:  foreach() argument must be of type array|object, null given in <b>[...]/htdocs/wordpress/wp-content/plugins/real-cookie-banner/inc/settings/Cookie.php</b> on line <b>353</b><br />
    {"settings":{"SETTING_BANNER_ACTIVE":

    Issue 3: The export seems to get stuck on some <br> tags in the export. I can only re-import the export after removing those.

    Should I send you the export file for analysis via email somewhere?

    Regards,
    Stefan

    Plugin Contributor Matthias Günter

    (@mguenter)

    Hey @roots84 !

    Thanks for the reproducing steps.

    It seems that the system where you export the data is already “broken”, e.g. missing “Essential” service group which did not get created correctly. Are you using WPML or PolyLang?

    Thread Starter TryAllTheThings

    (@roots84)

    Hello!

    Both exports didn’t use WPML, Polylang or similar plugins. The second export I was using last was even from the same website I was importing it back into. Same versions of everything (PHP, WP, plugins, etc.). Just the “Reset all” in between.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP Warning on backend and frontend (Cookie.php on Line 353)’ is closed to new replies.