Fatal Error in cleanCommentRelatedRows function
-
Hello, wpDiscuz team!
We are having an issue with your plugin on one of the sites we support.
This is the error we get in the debug log:
PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function WpdiscuzHelperOptimization::cleanCommentRelatedRows(), 1 passed in /wordpress-versions/5.7.3/wp-includes/class-wp-hook.php on line 292 and exactly 2 expected in /dom21465/wp-content/plugins/wpdiscuz/utils/class.WpdiscuzHelperOptimization.php:153 Stack trace: #0 /wordpress-versions/5.7.3/wp-includes/class-wp-hook.php(292): WpdiscuzHelperOptimization->cleanCommentRelatedRows('982131') #1 /wordpress-versions/5.7.3/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters('', Array) #2 /wordpress-versions/5.7.3/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #3 /dom21465/wp-content/plugins/akismet/class.akismet.php(421): do_action('deleted_comment', '982131') #4 /wordpress-versions/5.7.3/wp-includes/class-wp-hook.php(292): Akismet::delete_old_comments() #5 /wordpress-versions/5.7.3/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters('', Array) #6 /wordpress-versions/5.7.3/wp-includes/plugin.php(551): WP_Hook->do_action(Array) #7 /wordpress- in /dom21465/wp-content/plugins/wpdiscuz/utils/class.WpdiscuzHelperOptimization.php on line 153
I investigated more about this and it seems that the function cleanCommentRelatedRows is passed just the first argument instead of both.
That function is hooked to the “deleted_comment” action and expects two arguments to be passed to it, and then uses them without first checking if they exist. Thus, when Akismet does the “deleted_comment” action and passes just the first argument cleanCommentRelatedRows() throws a Fatal.This is my proposed fix:
public function cleanCommentRelatedRows($commentId, $comment) { $this->dbManager->deleteSubscriptions($commentId); $this->dbManager->deleteVotes($commentId); if ( ! empty( $comment->comment_post_ID ) ) { $this->cleanPostCache($comment->comment_post_ID); } }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Fatal Error in cleanCommentRelatedRows function’ is closed to new replies.