array_key_exists error
-
We’ve been trying to debug the following issue that we were seeing in our error log, and think we’ve found the problem, and a resolution.
[05-Nov-2013 15:48:02 UTC] PHP Warning: Illegal offset type in isset or empty in /wp-includes/cache.php on line 618 [05-Nov-2013 15:48:02 UTC] PHP Warning: array_key_exists() [<a href='function.array-key-exists'>function.array-key-exists</a>]: The first argument should be either a string or an integer in /wp-includes/cache.php on line 618
The above error was happening every 24 hours, and after some digging we found that it correlated to a cron task in WordPress scheduled by Akismet. Some debugging within the akismet_delete_old function (akismet.php) revealed that the following line was causing the error:
do_action( 'delete_comment', $comment_ids );
Further research indicated that the W3 Total Cache plugin was hooked onto the delete_comment action, however we don’t believe that’s where the fault lies. The WordPress Codex says for the ‘delete_comment’ action: Runs just before a comment is deleted. Action function arguments: comment ID..
In akismet.php, an array of comment IDs is submitted, causing issues for plugins using the action has defined in the WordPress Codex (a single Comment ID).
We were able to resolve the issue by replacing the do_action with the following:
foreach($comment_ids as $key=>$comment_id){ do_action( 'delete_comment', $comment_id ); }
Hopefully you can confirm this as an issue?
- The topic ‘array_key_exists error’ is closed to new replies.