WordPress.org

Make WordPress Core

Ticket #16565: 16565-akismet.php.patch

File 16565-akismet.php.patch, 1.7 KB (added by tillkruess, 4 years ago)

fixes notices in akismet

  • akismet.php

     
    254254        if ( !function_exists('add_comment_meta') ) 
    255255                return false; 
    256256 
     257        // set author's email to prevent E_NOTICE 
     258        if (!isset($akismet_last_comment['comment_author_email'])) 
     259                $akismet_last_comment['comment_author_email'] = '';      
     260                 
    257261        // wp_insert_comment() might be called in other contexts, so make sure this is the same comment 
    258262        // as was checked by akismet_auto_check_comment 
    259263        if ( is_object($comment) && !empty($akismet_last_comment) && is_array($akismet_last_comment) ) { 
     
    295299        global $akismet_api_host, $akismet_api_port, $akismet_last_comment; 
    296300 
    297301        $comment = $commentdata; 
    298         $comment['user_ip']    = $_SERVER['REMOTE_ADDR']; 
    299         $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT']; 
    300         $comment['referrer']   = $_SERVER['HTTP_REFERER']; 
     302        $comment['user_ip']    = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['HTTP_USER_AGENT'] : null; 
     303        $comment['user_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; 
     304        $comment['referrer']   = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; 
    301305        $comment['blog']       = get_option('home'); 
    302306        $comment['blog_lang']  = get_locale(); 
    303307        $comment['blog_charset'] = get_option('blog_charset'); 
    304308        $comment['permalink']  = get_permalink($comment['comment_post_ID']); 
    305309         
    306         $comment['user_role'] = akismet_get_user_roles($comment['user_ID']); 
     310        $comment['user_role'] = akismet_get_user_roles(isset($comment['user_ID']) ? $comment['user_ID'] : 0); 
    307311 
    308312        $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) ); 
    309313        $comment['akismet_comment_nonce'] = 'inactive';