• Resolved Curtiss Grymala

    (@cgrymala)


    On line 49 of the-events-calendar/common/src/Tribe/Admin/Notice/Archive_Slug_Conflict.php, the plugin attempts to evaluate the $dimissed_notices variable with the in_array() function. However, there’s nothing in the code preceding that call that checks to see if $dimissed_notices is actually an array before using in_array().

    In addition, this call seems to trigger any time anything within /wp-admin/ is invoked.

    This is problematic when you have AJAX calls on the front-end of your site, because:
    a) The wp_ajax_nopriv_{$action} call invokes something within /wp-admin/, which, in turn, triggers the maybe_add_admin_notice() function mentioned above.
    b) The wp_ajax_nopriv_{$action} action is only called when the user is not logged in. Therefore, the get_user_meta() function (more appropriately, the get_metadata() function) uses a $user_id of 0, which returns false rather than an array.

    Therefore, on the front-end, when you are not logged into the site, any AJAX call throws a PHP warning about in_array() expecting parameter 2 to be an array.

    I would recommend the following checks:
    1) Don’t run maybe_add_admin_notice() if this is an AJAX call
    2) Test the $dismissed_notices variable to make sure it’s an array before using it in in_array()

    Thanks.

    https://wordpress.org/plugins/the-events-calendar/

Viewing 2 replies - 1 through 2 (of 2 total)
  • joinfof

    (@joinfof)

    Hey Curtiss,

    Thanks so much for the in-depth post. I’ll pass this information along to our developers as I’m sure they’ll find it helpful.

    Again, thanks for taking the time and enjoy your week!

    Geoff Graham

    (@geoffgraham)

    Hey Curtiss,

    Just wanted to follow up and let you know that we released version 4.1.1 last night and it included a fix for this issue. Please update to the latest version if you haven’t already and do let us know if you continue to see any issues from there. 🙂

    Cheers and thanks for your patience while we worked on this!

    Geoff

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

The topic ‘PHP Warning After Update to 4.1’ is closed to new replies.