Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#23144 closed defect (bug) (duplicate)

Non writeable uploads folder may result in URLs to existing attachments fallbacking to use GUID

Reported by: eskapism's profile eskapism Owned by:
Milestone: Priority: normal
Severity: minor Version: 2.7
Component: Media Keywords:
Focuses: Cc:


When using wp_get_attachment_url() the returned url may fall back to using the value stored in the GUID field, if the uploads folder is not writeable.

I think this only happens if the uploads folder for the current year + month does not exists.

Reason for this is in wp_upload_dir(): it returns everything ok, including an error like "Unable to create directory wp-content/uploads/2013/01. Is its parent directory writable by the server?" which makes the wp_get_attachment_url() function think something is wrong and therefor uses GUID instead, since it does a check for just FALSE and not the type of error.

In my example I am getting an attachment/file that exists in the folder "uploads/2012/12", so the month/folder 01 is not necessary at all.

I don't see the need for falling back to GUID because of a non-writeable uploads folder since this should only be considered wrong when adding files, not when reading existing files. All other information for getting the file is correct. Also, perhaps you can spare some MS if you skip the does-folder-exist-for-current-month checks when just getting file info.

Change History (3)

#1 @SergeyBiryukov
10 years ago

  • Component changed from General to Media
  • Version changed from 3.5 to 2.7

Related: [8796] (for #7622).

#2 @wpdavis
9 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #26992.

#3 @DrewAPicture
9 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.