Ticket #18310: 18310-2.diff

File 18310-2.diff, 1.2 KB (added by ericmann, 9 months ago)

Patch refresh, and also check that $file->guid is actually set before using it.

Line 
1Index: wp-includes/class-wp-xmlrpc-server.php
2===================================================================
3--- wp-includes/class-wp-xmlrpc-server.php      (revision 21548)
4+++ wp-includes/class-wp-xmlrpc-server.php      (working copy)
5@@ -3953,7 +3953,7 @@
6                $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );
7                if ( is_array( $attachments ) ) {
8                        foreach ( $attachments as $file ) {
9-                               if ( strpos( $post_content, $file->guid ) !== false )
10+                               if ( isset( $file->guid ) && strpos( $post_content, $file->guid ) !== false )
11                                        $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) );
12                        }
13                }
14Index: wp-includes/post.php
15===================================================================
16--- wp-includes/post.php        (revision 21548)
17+++ wp-includes/post.php        (working copy)
18@@ -3784,6 +3784,10 @@
19                $wpdb->update( $wpdb->posts, compact("post_name"), array( 'ID' => $post_ID ) );
20        }
21 
22+       // Set GUID
23+       if ( ! isset( $guid ) )
24+               $wpdb->update ( $wpdb->posts, arrray( 'guid' => get_permalink( $post_ID ) ), array( 'ID' => $post_ID ) );
25+
26        wp_set_post_categories($post_ID, $post_category);
27 
28        if ( $file )