Make WordPress Core


Ignore:
Timestamp:
09/13/2013 10:17:51 PM (11 years ago)
Author:
wonderboymusic
Message:

Fix some undefined index notices related to Comment unit tests:

  • There are several places where a $_POST index was unchecked before setting a variable
  • In wp_notify_postauthor(), $comment was being returned null, but its properties were being accessed.
  • In check_ajax_referer(), 3 different values can be checked for nonce on $_REQUEST, but only 1 had an isset()

See #25282.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r25318 r25433  
    831831 */
    832832function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
    833     if ( $query_arg )
     833    $nonce = '';
     834
     835    if ( $query_arg && isset( $_REQUEST[$query_arg] ) )
    834836        $nonce = $_REQUEST[$query_arg];
    835     else
    836         $nonce = isset($_REQUEST['_ajax_nonce']) ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce'];
     837
     838    if ( isset( $_REQUEST['_ajax_nonce'] ) )
     839        $nonce = $_REQUEST['_ajax_nonce'];
     840
     841    if ( isset( $_REQUEST['_wpnonce'] ) )
     842        $nonce = $_REQUEST['_wpnonce'];
    837843
    838844    $result = wp_verify_nonce( $nonce, $action );
     
    10101016function wp_notify_postauthor( $comment_id, $comment_type = '' ) {
    10111017    $comment = get_comment( $comment_id );
     1018    if ( empty( $comment ) )
     1019        return false;
     1020
    10121021    $post    = get_post( $comment->comment_post_ID );
    10131022    $author  = get_userdata( $post->post_author );
Note: See TracChangeset for help on using the changeset viewer.