[wp-trac] [WordPress Trac] #23144: Non writeable uploads folder may result in URLs to existing attachments fallbacking to use GUID
WordPress Trac
noreply at wordpress.org
Tue Jan 8 16:19:45 UTC 2013
#23144: Non writeable uploads folder may result in URLs to existing attachments
fallbacking to use GUID
-----------------------------+--------------------------
Reporter: eskapism | Type: defect (bug)
Status: new | Priority: normal
Milestone: Awaiting Review | Component: General
Version: 3.5 | Severity: minor
Keywords: |
-----------------------------+--------------------------
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.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/23144>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list