WordPress.org

Make WordPress Core

Opened 16 months ago

Last modified 16 months ago

#23144 new defect (bug)

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

Reported by: eskapism Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 2.7
Component: Media Keywords:
Focuses: Cc:

Description

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 (1)

comment:1 SergeyBiryukov16 months ago

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

Related: [8796] (for #7622).

Note: See TracTickets for help on using tickets.