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_notices
variable with thein_array()
function. However, there’s nothing in the code preceding that call that checks to see if$dimissed_notices
is 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_id
of 0, which returnsfalse
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 runmaybe_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 inin_array()
Thanks.
- The topic ‘PHP Warning After Update to 4.1’ is closed to new replies.