Opened 22 months ago
Last modified 22 months ago
#18286 new defect (bug)
Upgrade script to fix non-unique page GUIDs
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Upgrade/Install | Version: | 3.2.1 |
| Severity: | major | Keywords: | has-patch |
| Cc: | nacin |
Description
There were versions of WordPress prior to 3.1 that created non-unique GUIDs in the posts table.
http://core.trac.wordpress.org/ticket/15041
This bug is fixed, but the bad data persists in many WP installs. Attached is a proof-of-concept plugin that could be included in the WordPress upgrade process to clean up these GUIDs.
In the interim, I'll probably release this as a plugin as we've got some folks using tools we built that need this fix ASAP.
Attachments (2)
Change History (12)
alexkingorg — 22 months ago
comment:1
alexkingorg — 22 months ago
- Keywords has-patch added
Here is a patch that integrates the previous attached code cleanly into the WP upgrade process. This also incorporates the changes suggested in ticket #18315
Note that the non-unique GUID issue affects pages and custom post types, this means that any feeds that use custom post types are likely to be invalid due to duplicate GUIDs.
comment:3
alexkingorg — 22 months ago
I'm pretty sure it also affected hierarchical custom post types as well. We just cleaned up a few dozen FAQs on our site that all had a GUID of: http://crowdfavorite.com/support/faq/
comment:5
alexkingorg — 22 months ago
For reference purposes, we had 120 pages and custom post types that all had non-unique GUIDs. I was using our DB as a test to write the SQL queries against.
Think there is at least one older ticket proposing to change the GUID to using a truly random string. Perhaps it's time to implement that as we require MySQL 5 now. Don't think it will slow us down much if we go to the db and pull an UUID before saving a post for the first time.
Related: #6492.
comment:7
follow-ups:
↓ 8
↓ 9
alexkingorg — 22 months ago
Changing existing GUID values would break anything that relies on those values. Adding a new UUID field seems fine to me, but please don't change valid GUIDs in the process.
Replying to alexkingorg:
Changing existing GUID values would break anything that relies on those values. Adding a new UUID field seems fine to me, but please don't change valid GUIDs in the process.
Same goes for an upgrade script, actually. Granted, the only thing that would break might be a feed reader, but still.
Replying to alexkingorg:
Changing existing GUID values would break anything that relies on those values.
Didn't mean to suggest changing existing GUIDs only switching it to use an UUID instead of the permalink for new posts. If we go that way we probably can use UUIDs to replace any duplicate GUIDs too.
Adding a new UUID field seems fine to me, but please don't change valid GUIDs in the process.
Don't think another field is needed.
comment:10
alexkingorg — 22 months ago
Same goes for an upgrade script, actually. Granted, the only thing that would break might be a feed reader, but still.
Technically true, but the only thing changing would be rows whose GUIDs were already "broken" and not usable.
Didn't mean to suggest changing existing GUIDs only switching it to use an UUID instead of the permalink for new posts. If we go that way we probably can use UUIDs to replace any duplicate GUIDs too.
Ah, that makes sense. Certainly, I don't care what the format of the value is.

Proof of concept plugin to uniquify GUIDs in possts table.