[wp-trac] [WordPress Trac] #50025: Media Library (Ajax) Filters Not Showing New Uploads
WordPress Trac
noreply at wordpress.org
Mon May 4 13:05:57 UTC 2020
#50025: Media Library (Ajax) Filters Not Showing New Uploads
--------------------------+-----------------------------
Reporter: teamdnk | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.5
Component: Media | Version: 5.4
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: ui, javascript
--------------------------+-----------------------------
Changes (by afercia):
* keywords: => needs-patch
* milestone: Awaiting Review => 5.5
Comment:
@teamdnk thanks for further testing.
> the issue happens when you toggle back to "All Dates" at least once
before uploading new media.
> it seems to be caching the results with out re-querying new results
after a new upload.
Yup, the media views collections do implement a caching mechanism. They
check whether a query has already been made and in that case they just re-
display the cached collection, avoiding a new fetch. I'm not sure I fully
understand how this mechanism works, yet. The fact the media views inner
workings aren't described nor documented anywhere after more than 7 years
from their introduction doesn't help.
Regardless, I was able to reproduce something similar to the steps you
provided back to WordPress 4.9 and I guess it always happened on all
previous versions:
- go to the Media Library so that attachments are fetched for the first
time
- filter by a previous month
- in the filtered month view, drag and drop a new attachment
- switch back the filter to "All dates"
- the new attachment is visible
- but...
- switch back to the previously selected month
- drag and drop one more attachment
- switch back the filter to "All dates"
- this time, the new attachment is ''not'' visible
This translates to:
- first fetch: the "all" view is not cached yet
- switch to a month: the month view is not cached yet
- add attachment, switch to "all" view
- the "all" view is not cached yet: a new fetch occurs which includes the
new attachment and the collection gets cached
- switch to month: the month view is now cached
- add attachment, switch to "all" view
- the "all" view is cached and will display the previous attachments,
ignoring the new one
To my understanding, there's a flaw in the media views collections design.
When attachments are added, the cache should be flushed to trigger a new
fetch.
This doesn't seem to happen when attachments are removed. Although the
collection is cached (there's no new fetch), the deleted attachment is not
displayed, as expected. Agani to my understanding, this works correctly
because `destroyed` attachments are filtered out.
Moving to 5.5 consideration.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50025#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list