PHP Warning After Update to 4.1
-
On line 49 of
the-events-calendar/common/src/Tribe/Admin/Notice/Archive_Slug_Conflict.php, the plugin attempts to evaluate the$dimissed_noticesvariable with thein_array()function. However, there’s nothing in the code preceding that call that checks to see if$dimissed_noticesis actually an array before usingin_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) Thewp_ajax_nopriv_{$action}call invokes something within /wp-admin/, which, in turn, triggers themaybe_add_admin_notice()function mentioned above.
b) Thewp_ajax_nopriv_{$action}action is only called when the user is not logged in. Therefore, theget_user_meta()function (more appropriately, theget_metadata()function) uses a$user_idof 0, which returnsfalserather 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 runmaybe_add_admin_notice()if this is an AJAX call
2) Test the$dismissed_noticesvariable to make sure it’s an array before using it inin_array()Thanks.
-
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!
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
The topic ‘PHP Warning After Update to 4.1’ is closed to new replies.