WordPress.org

Make WordPress Core

Opened 23 months ago

Last modified 23 months ago

#18286 new defect (bug)

Upgrade script to fix non-unique page GUIDs

Reported by: alexkingorg 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)

cf-guid-fix.php (1.9 KB) - added by alexkingorg 23 months ago.
Proof of concept plugin to uniquify GUIDs in possts table.
patch.diff (1.3 KB) - added by alexkingorg 23 months ago.
Cleanly integrate changes into upgrade process

Download all attachments as: .zip

Change History (12)

alexkingorg23 months ago

Proof of concept plugin to uniquify GUIDs in possts table.

comment:1 alexkingorg23 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.

alexkingorg23 months ago

Cleanly integrate changes into upgrade process

comment:2 nacin23 months ago

Hmm. This only affected pages, IIRC.

comment:3 alexkingorg23 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:4 nacin23 months ago

Well that sucks.

comment:5 alexkingorg23 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.

comment:6 azaozz23 months ago

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.

Last edited 23 months ago by azaozz (previous) (diff)

comment:7 follow-ups: alexkingorg23 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.

comment:8 in reply to: ↑ 7 nacin23 months ago

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.

comment:9 in reply to: ↑ 7 azaozz23 months ago

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 alexkingorg23 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.

Version 0, edited 23 months ago by alexkingorg (next)
Note: See TracTickets for help on using tickets.