[wp-trac] [WordPress Trac] #39439: Attachment update and GUID

WordPress Trac noreply at wordpress.org
Mon Jan 2 15:21:21 UTC 2017


#39439: Attachment update and GUID
-------------------------------+------------------------------
 Reporter:  jlambe             |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  trunk
 Severity:  normal             |  Resolution:
 Keywords:  close              |     Focuses:
-------------------------------+------------------------------
Changes (by MattyRob):

 * keywords:   => close


Comment:

 @jlambe

 Thanks for posting this issue, I'm not entirely sure it's a bug though as
 the GUID is not expected to change by the WordPress core code.

 That said - it is possible to force the issue if desired. You said above
 you set it to change - how have you done this? Something similat to the
 code snippet below works for me in a different situation where I change
 GUIDs. You'll need to create your new GUID and insert it into the database
 table at the correct point.

 Obviously messing with the database directly can cause issues so be
 careful when testing this and your own code.


 {{{
 if ( 'inherit' === $post->post_status ) {
         $guid = get_option( 'siteurl' ) . '/?p=' . $new_id;
         // update the GUID
         $wpdb->update( $wpdb->posts,
                 array(
                         'guid' => $guid,
                 ),
                 array(
                         'ID' => $post_id,
                 )
         );
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39439#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list