Make WordPress Core

Changeset 34015


Ignore:
Timestamp:
09/10/2015 08:50:12 PM (9 years ago)
Author:
wonderboymusic
Message:

Comments/PHP Notices: check that a parent comment exists before displaying an orphan's link to it in the admin.

Props rachelbaker.
Fixes #33710.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-comment.php

    r33891 r34015  
    120120if ( $comment->comment_parent ) :
    121121    $parent      = get_comment( $comment->comment_parent );
    122     $parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
    123     $name        = get_comment_author( $parent->comment_ID );
    124 ?>
    125 <div class="misc-pub-section misc-pub-reply-to">
    126     <?php printf(
    127         /* translators: comment link */
    128         __( 'In reply to: %s' ),
    129         '<b><a href="' . $parent_link . '">' . $name . '</a></b>'
    130     ); ?>
    131 </div>
    132 <?php endif; ?>
     122    if ( $parent ) :
     123        $parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
     124        $name        = get_comment_author( $parent->comment_ID );
     125    ?>
     126    <div class="misc-pub-section misc-pub-reply-to">
     127        <?php printf(
     128            /* translators: comment link */
     129            __( 'In reply to: %s' ),
     130            '<b><a href="' . $parent_link . '">' . $name . '</a></b>'
     131        ); ?>
     132    </div>
     133<?php endif;
     134endif; ?>
    133135
    134136<?php
  • trunk/src/wp-admin/includes/class-wp-comments-list-table.php

    r33986 r34015  
    608608        if ( $comment->comment_parent ) {
    609609            $parent = get_comment( $comment->comment_parent );
    610             $parent_link = esc_url( get_comment_link( $parent ) );
    611             $name = get_comment_author( $parent );
    612             printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );
     610            if ( $parent ) {
     611                $parent_link = esc_url( get_comment_link( $parent ) );
     612                $name = get_comment_author( $parent );
     613                printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );
     614            }
    613615        }
    614616
Note: See TracChangeset for help on using the changeset viewer.