Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#33386 closed defect (bug) (fixed)

Media GUID should never be treated as the filename or URL

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

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 9 years ago.
33386.2.diff (671 bytes) - added by kitchin 9 years ago.
One more, not tested.

Download all attachments as: .zip

Change History (8)

#1 @wonderboymusic
9 years ago

  • Milestone changed from Awaiting Review to 4.4
  • Owner set to wonderboymusic
  • Status changed from new to assigned

#2 @wonderboymusic
9 years ago

#33872 was marked as a duplicate.

@wonderboymusic
9 years ago

#3 @wonderboymusic
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

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
9 years ago

One more, not tested.

#4 @kitchin
9 years ago

  • Keywords has-patch added
  • Resolution fixed deleted
  • Status changed from closed to reopened

#5 @wonderboymusic
9 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 34171:

Use get_attached_file() in attachment_submitbox_metadata().

Props kitchin.
Fixes #33386.

#6 @nerrad
9 years ago

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

Note: See TracTickets for help on using tickets.