WordPress.org

Make WordPress Core

Changeset 24182


Ignore:
Timestamp:
05/07/13 11:46:35 (22 months ago)
Author:
SergeyBiryukov
Message:

Avoid PHP notices in Media Library if an attachment parent does not exist. props trepmal, viniciusmassuchetto, alex-ye, adamsilverstein for initial patches. fixes #22312. fixes #23154.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-media-list-table.php

    r23430 r24182  
    303303 
    304304    case 'parent': 
    305         if ( $post->post_parent > 0 ) { 
    306             if ( get_post( $post->post_parent ) ) { 
    307                 $title =_draft_or_post_title( $post->post_parent ); 
    308             } 
     305        if ( $post->post_parent > 0 && get_post( $post->post_parent ) ) { 
     306            $title = _draft_or_post_title( $post->post_parent ); 
    309307?> 
    310308            <td <?php echo $attributes ?>><strong> 
    311                 <?php if( current_user_can( 'edit_post', $post->post_parent ) ) { ?> 
     309                <?php if ( current_user_can( 'edit_post', $post->post_parent ) ) { ?> 
    312310                    <a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"> 
    313311                        <?php echo $title ?></a><?php 
     
    321319?> 
    322320            <td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br /> 
    323             <?php if( $user_can_edit ) {?> 
     321            <?php if ( $user_can_edit ) { ?> 
    324322                <a class="hide-if-no-js" 
    325323                    onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;" 
  • trunk/wp-includes/link-template.php

    r23660 r24182  
    302302 
    303303    $post = get_post( $post ); 
    304  
    305     if ( $wp_rewrite->using_permalinks() && ( $post->post_parent > 0 ) && ( $post->post_parent != $post->ID ) ) { 
    306         $parent = get_post($post->post_parent); 
     304    $parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false; 
     305 
     306    if ( $wp_rewrite->using_permalinks() && $parent ) { 
    307307        if ( 'page' == $parent->post_type ) 
    308308            $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front 
Note: See TracChangeset for help on using the changeset viewer.