Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#33386 closed defect (bug) (fixed)

Media GUID should never be treated as the filename or URL

Reported by: rmccue Owned by: wonderboymusic
Priority: normal Milestone: 4.4
Component: Media Version:
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

Right now, there's a bunch of code in core (especially around display) that assumes a media item (attachment post) has a GUID which points to the URL. One instance of this was fixed in #32531, but others still exist.

This is problematic in at least two circumstances I can think of:

  1. If you change GUIDs to be a different system than just the permalink, this breaks media. For example, using UUIDs instead will give things like urn:uuid:f468f435-80bd-4709-bb52-f5c3e782a2ac in your media library.
  2. If you import media from another site, the filename may change, and the URL almost certainly will. Right now, the importer updates the GUID, which is a pretty big no-no. This has the potential to break all sorts of things.

These should be switched from $attachment->guid to get_attached_file( $attachment->ID ) instead.

Attachments (2)

33386.diff (5.7 KB ) - added by wonderboymusic 11 years ago.
33386.2.diff (671 bytes ) - added by kitchin 11 years ago.
One more, not tested.

Download all attachments as: .zip

Change History (8)

#1 @wonderboymusic
11 years ago

  • Milestone Awaiting Review4.4
  • Owner set to wonderboymusic
  • Status newassigned

#2 @wonderboymusic
11 years ago

#33872 was marked as a duplicate.

#3 @wonderboymusic
11 years ago

  • Resolutionfixed
  • Status assignedclosed

In 34163:

Don't ever use the guid value when retrieving URLs for media, use wp_get_attachment_url(). Use get_attached_file() for path to file.

Fixes #33386.

@kitchin
11 years ago

One more, not tested.

#4 @kitchin
11 years ago

  • Keywords has-patch added
  • Resolution fixed
  • Status closedreopened

#5 @wonderboymusic
11 years ago

  • Resolutionfixed
  • Status reopenedclosed

In 34171:

Use get_attached_file() in attachment_submitbox_metadata().

Props kitchin.
Fixes #33386.

#6 @nerrad
11 years ago

hey @wonderboymusic, I think #33319 is related to this also no?

Note: See TracTickets for help on using tickets.