• Resolved viratraaz

    (@viratraaz)


    After looking everything, I found that:
    there is a function called
    wp_new_comment( $commentdata, $avoid_die = false )
    in site_directory/wp-includes/comment.php where
    do_action( ‘comment_post’, $comment_ID, $commentdata[‘comment_approved’], $commentdata );
    is not working.
    I want to know where this function is defined and where the file is included?
    According to my analysis ‘do_action’ function is being called from site_directory/wp-includes/plugin.php but I don’t see enough arguments in the defined function.

    Please help.

    {temporary solution: comment line
    do_action( ‘comment_post’, $comment_ID, $commentdata[‘comment_approved’], $commentdata );
    which is in
    wp_new_comment( $commentdata, $avoid_die = false )
    function from file site_directory/wp-includes/comment.php}

Viewing 6 replies - 16 through 21 (of 21 total)
  • Thread Starter viratraaz

    (@viratraaz)

    first:
    I download fresh wordpress 5.1.1 from https://wordpress.org/download/
    I compared code from file site_directory/wp-comments-post.php , site_directory/wp-includes/comment.php and site_directory/wp-includes/plugin.php
    I found no difference in code.

    Second:
    I installed and activated WordFence.
    Then I ran scan and I found no issue https://ibb.co/mrj3GPh

    Thread Starter viratraaz

    (@viratraaz)

    Please download fresh copy of wordpress 5.1.1 from https://wordpress.org/download/
    and install it. Then look for the file

    site_directory/wp-includes/comment.php

    Search for

    function wp_new_comment(

    You’ll see a function is defined with the name

    wp_new_comment( $commentdata, $avoid_die = false )

    at the last second line of this function, you’ll find a function being called

    do_action( ‘comment_post’, $comment_ID, $commentdata[‘comment_approved’], $commentdata );

    Please tell me the use of this function (do_action) here

    • This reply was modified 4 years, 12 months ago by viratraaz.

    Please see the suggestions from @shamim51 and @otto42
    The search feature in my favorite text editor was broken and I did not realize it until after doing more digging. Sorry, but I am at a loss since your scan came back clean I think it is best if look at suggestions from others. Thank you for understanding and best of luck finding a fix.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Please tell me the use of this function (do_action) here

    The do_action call is an “action hook”. By itself, it does nothing at all. It provides a point for functions from elsewhere in the code to hook in and do things at that point in the processing.

    Like I said, the do_action is not your real problem. You have some other code using that hook, probably in a plugin, and that is your real problem. You need to deactivate your plugins in order to find out where the problem lies.

    Thread Starter viratraaz

    (@viratraaz)

    Thanks @otto42 I found solution. I also learnt many wordpress core functions now.

    Although it took 2 days to solve it. But the solution is very easy.

    Final Solution:

    Step 1: Change your theme for few moments, (choose any light theme).
    Step 2: Disable all installed plugins.
    Step 3: Activate back your desired theme and plugins.
    Step 4: Install a fresh wordpress in your local machine.
    Step 6: Copy local_directory/wp-includes/class-phpmailer.php and local_directory/wp-includes/class-smtp.php
    Step 7: Paste this file here: site_directory/wp-includes/ (replace both files if these are already there)

    Solution close

    [ Contact URL removed, keep support in these forums ]

    Reason for this bug: Some plugins or themes create it’s own PHPmailer and delete some files conaining PHPmailer. After uninstlling or deactivating them, required PHPmailer get disappear and it start creating many errors.

    Explanations: During debugging process, I found that in site_directory/wp-includes/pluggable.php, wp_mail function is defined. $phpmailer variable is globally called. after calling this variable, it checks for if it has PHPmailer instance. If $phpmailer was not defined properly earlier, it includes site_directory/wp-includes/class-phpmailer.php and site_directory/wp-includes/class-smtp.php . But I found that site_directory/wp-includes/class-phpmailer.php is unavailable. I added this file and bug got fixed.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Reason for this bug: Some plugins or themes create it’s own PHPmailer and delete some files conaining PHPmailer. After uninstlling or deactivating them, required PHPmailer get disappear and it start creating many errors.

    No theme or plugin should ever modify the WordPress core files.

    If they do, please tell us what theme or plugin they are, and we will have words with them.

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘Comment gets stuck at https://randomwpsite.com/wp-comments-post.php’ is closed to new replies.