• Resolved pranciskus

    (@pranciskus)


    When posting a comment as a guest, the following warning appears. It seems that display_attachment filter is applied for both new comments before saving to the DB during a POST request and for existing ones via GET.

    
    <code>Notice: Trying to get property 'comment_ID' of non-object in /var/www/html/wp-includes/comment-template.php on line 677 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:677) in /var/www/html/wp-includes/comment.php on line 577 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:677) in /var/www/html/wp-includes/comment.php on line 578 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:677) in /var/www/html/wp-includes/comment.php on line 579 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:677) in /var/www/html/wp-includes/pluggable.php on line 1340 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:677) in /var/www/html/wp-includes/pluggable.php on line 1343

    Hacky solution for init_hooks():

    if ( $_SERVER['REQUEST_METHOD'] === 'GET' ) {
    
    			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    
    			if ( $this->is_attachment_displayed() ) {
    				add_filter( 'comment_text', array( $this, 'display_attachment' ) ); 
    			}
    	
    			if ( $this->get_option( 'autoembed_links' ) && ! is_admin() ) {
    				add_filter( 'comment_text', array( $this, 'autoembed_links' ), 5 );
    			}
    
    		}
    
    • This topic was modified 3 years, 5 months ago by pranciskus.
    • This topic was modified 3 years, 5 months ago by pranciskus.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter pranciskus

    (@pranciskus)

    Notice: Trying to get property 'comment_ID' of non-object in /var/www/html/wp-includes/comment-template.php on line 678
    
    #0 get_comment_ID() called at [/var/www/html/wp-content/plugins/dco-comment-attachment/includes/class-dco-ca-base.php:74]
    #1 DCO_CA_Base->get_attachment_id() called at [/var/www/html/wp-content/plugins/dco-comment-attachment/includes/class-dco-ca-base.php:93]
    #2 DCO_CA_Base->has_attachment() called at [/var/www/html/wp-content/plugins/dco-comment-attachment/includes/class-dco-ca.php:504]
    #3 DCO_CA->display_attachment(asd) called at [/var/www/html/wp-includes/class-wp-hook.php:305]
    #4 WP_Hook->apply_filters(asd, Array ([0] => asd,[1] => ,[2] => Array ())) called at [/var/www/html/wp-includes/plugin.php:189]
    #5 apply_filters(comment_text, XXXXXX, , Array ()) called at [/var/www/html/wp-includes/comment.php:48]
    #6 check_comment(XXXXXX, , , XXXXXX, XXXXXX, XXXXXX, review) called at [/var/www/html/wp-includes/comment.php:822]
    #7 wp_allow_comment(XXXXXX) called at [/var/www/html/wp-includes/comment.php:2248]
    #8 wp_new_comment(XXXXXX) called at [/var/www/html/wp-includes/comment.php:3567]
    #9 wp_handle_comment_submission(XXXXXX) called at [/var/www/html/wp-comments-post.php:25]
    
    Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:666) in /var/www/html/wp-includes/comment.php on line 577
    Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:666) in /var/www/html/wp-includes/comment.php on line 578
    Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:666) in /var/www/html/wp-includes/comment.php on line 579
    Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:666) in /var/www/html/wp-includes/pluggable.php on line 1340
    Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/comment-template.php:666) in /var/www/html/wp-includes/pluggable.php on line 1343`
    
    
    • This reply was modified 3 years, 5 months ago by pranciskus.
    Plugin Author Denis Yanchevskiy

    (@denisco)

    Hello @pranciskus,

    Thank you for the bug report.

    It’s probably due to a problem with get_comment_ID function. It doesn’t check if the comment exists.

    I’ll think about what can be done about it.

    P.S. Related tiket — https://core.trac.www.ads-software.com/ticket/54149.

    Plugin Author Denis Yanchevskiy

    (@denisco)

    Fixed in version 2.3.0

    HI sir ,

    I am facing same problem in the error log kindly help . pleaseeee

    [29-Apr-2022 02:48:03 UTC] PHP Notice: Undefined variable: user_ID in /home1/jetlinem/public_html/wp-content/themes/zox-news/comments.php on line 49

    HI sir ,

    I am facing same problem in the error log kindly help . pleaseeee

    [29-Apr-2022 02:48:03 UTC] PHP Notice: Undefined variable: user_ID in /home1/jetlinem/public_html/wp-content/themes/zox-news/comments.php on line 49

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Trying to get property ‘comment_ID’ of non-object’ is closed to new replies.