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.

git-svn-id: http://core.svn.wordpress.org/trunk@24182 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2013-05-07 11:46:35 +00:00
parent d55dfbf477
commit 23479edf3f
2 changed files with 6 additions and 8 deletions

View File

@ -302,10 +302,8 @@ foreach ( $columns as $column_name => $column_display_name ) {
break; break;
case 'parent': case 'parent':
if ( $post->post_parent > 0 ) { if ( $post->post_parent > 0 && get_post( $post->post_parent ) ) {
if ( get_post( $post->post_parent ) ) {
$title = _draft_or_post_title( $post->post_parent ); $title = _draft_or_post_title( $post->post_parent );
}
?> ?>
<td <?php echo $attributes ?>><strong> <td <?php echo $attributes ?>><strong>
<?php if ( current_user_can( 'edit_post', $post->post_parent ) ) { ?> <?php if ( current_user_can( 'edit_post', $post->post_parent ) ) { ?>

View File

@ -301,9 +301,9 @@ function get_attachment_link( $post = null, $leavename = false ) {
$link = false; $link = false;
$post = get_post( $post ); $post = get_post( $post );
$parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false;
if ( $wp_rewrite->using_permalinks() && ( $post->post_parent > 0 ) && ( $post->post_parent != $post->ID ) ) { if ( $wp_rewrite->using_permalinks() && $parent ) {
$parent = get_post($post->post_parent);
if ( 'page' == $parent->post_type ) if ( 'page' == $parent->post_type )
$parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
else else