[wp-trac] [WordPress Trac] #39439: Attachment update and GUID
WordPress Trac
noreply at wordpress.org
Mon Jan 2 12:58:09 UTC 2017
#39439: Attachment update and GUID
-------------------------------+-----------------------------
Reporter: jlambe | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
I have a "special" case scenario related to media library attachments.
For the context, I've built a plugin that connects to an external server
and sync images stored into the remote server into local WordPress media
library. The importer upload files, generate the thumbnails and create a
new "attachment" post.
Now, an import process is ran everyday, and basically we re-import the
remote images into WordPress but in order to avoid duplicates, we're
updating existing attachments if exist. Now, during this update process,
we only remove the files stored into the `uploads` directory, import the
new one with its thumbnails and update the attachment post.
Before doing so, our first approach was to check if an attachment exists,
if exists, delete the attachment + its files and then simply create a new
attachment. This first approach works but we're having huge ID number into
the DB after the import as it generates thousand of new records which we
didn't want. So now, only the files are updated, if an attachment post
exists, we update its metadata and everything works as expected.
Now the issue/remark we have is that during the update of the attachment
post, each time we import the new image file, we set the `guid` property
to change and use the new imported file path. But when we check the
database table, the `guid` is not updated at all and reflects the path to
the image file imported the first time. Looking at source code, during an
update, the `guid` is not modified in general as for RSS feeds we need
that unique `guid`.
Our question is, is it relevant in this scenario to keep old `guid`
property that points to a file that no longer exists? and so should we
allow the `guid` to be updated by default in core for the attachment?
If RSS readers need that `guid`, why attachments use the file path and not
an attachment page permalink ? Is there another location that uses this
`guid` property in place of the meta data for the file path ?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39439>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list