# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: \trunk\wp-includes
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: link-template.php
--- link-template.php Base (BASE)
+++ link-template.php Locally Modified (Based On LOCAL)
@@ -301,24 +301,33 @@
 	$link = false;
 
 	$post = get_post( $post );
+        
+        if ( empty( $post ) )
+            return null;
 
 	if ( $wp_rewrite->using_permalinks() && ( $post->post_parent > 0 ) && ( $post->post_parent != $post->ID ) ) {
 		$parent = get_post($post->post_parent);
-		if ( 'page' == $parent->post_type )
-			$parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
-		else
-			$parentlink = get_permalink( $post->post_parent );
+                
+                if ( ! empty( $parent ) ) {
+                    
+                        if ( 'page' == $parent->post_type )
+                                $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
+                        else
+                                $parentlink = get_permalink( $post->post_parent );
 
-		if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
-			$name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
-		else
-			$name = $post->post_name;
+                        if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
+                                $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
+                        else
+                                $name = $post->post_name;
 
-		if ( strpos($parentlink, '?') === false )
-			$link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' );
+                        if ( strpos($parentlink, '?') === false )
+                                $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' );
 
-		if ( ! $leavename )
-			$link = str_replace( '%postname%', $name, $link );
+                        if ( ! $leavename )
+                                $link = str_replace( '%postname%', $name, $link );
+                        
+                }
+
 	}
 
 	if ( ! $link )
