[wp-trac] [WordPress Trac] #44595: wp_insert_post() inserts wrong GUID (adds http:// prefix)

WordPress Trac noreply at wordpress.org
Tue Jul 17 19:31:34 UTC 2018


#44595: wp_insert_post() inserts wrong GUID (adds http:// prefix)
--------------------------+------------------------------
 Reporter:  Looimaster    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  2nd-opinion   |     Focuses:
--------------------------+------------------------------

Comment (by Looimaster):

 I think this is a bug because:

 1. Maybe as you say

     "...WordPress uses GUIDs as an actual URL for RSS feeds, and so GUIDs
 need to be a real URL rather than an arbitrary text string..."

 and that's fine with me. You can generate `http://example.com/` as your
 GUIDs by default.

 2. But when a user explicitly sets a GUID to an actual GUID in for example
 `123e4567-e89b-12d3-a456-426655440000` format then in my opinion that
 shouldn't be modified by WordPress.

 3. By definition (and expectation) GUID is a defined concept
 (https://en.wikipedia.org/wiki/Universally_unique_identifier). WordPress
 currently uses this concept in an unofficial/arbitrary way if it really
 uses it as `"...actual URL for RSS feeds..."`.

 In the RSS feed I only see `<guid
 isPermaLink="false">http://example.com/?p=123</guid>` so I don't think
 that GUID must be a URL. It could be anything.

 I think GUID should be restricted to being an actual GUID as defined by
 Wikipedia (because it's a great and useful idea and the only column that I
 can count on being globally unique and I could use it to for example
 synchronize the content between multiple sites) and if you need
 `"...actual URL for RSS feeds..."` then that shouldn't be named "GUID" but
 something else like `feed_link`.

 **So I vote for implementing this fix:**
 1. For new posts inserted like `wp_insert_post( array( "post_title" =>
 "Some title" ) )` generate whatever you like.
 2. But for new posts inserted like `wp_insert_post( array( "post_title" =>
 "Some title", "guid" => "abc123" ) )` (where user explicitly indicates
 that they want to actually use GUID concept for something) don't modify
 it.

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


More information about the wp-trac mailing list