From a8b5b715908e02befce68e228680f7fbcf281b4d Mon Sep 17 00:00:00 2001 From: Anthony Burchell Date: Fri, 29 Jan 2021 01:34:05 +0000 Subject: [PATCH] Media: Remove caching from filter by date in media library. Previously, newly uploaded media attachments were missing when filtering media items by date due to lack of cache invalidation. Props adamsilverstein, teamdnk, afercia, Mista-Flo, joedolson, youknowriad, talldanwp. Fixes #50025. git-svn-id: https://develop.svn.wordpress.org/trunk@50067 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/media/models/attachments.js | 1 - src/js/media/models/query.js | 14 ++------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/js/media/models/attachments.js b/src/js/media/models/attachments.js index f80cac42f6..5661df3052 100644 --- a/src/js/media/models/attachments.js +++ b/src/js/media/models/attachments.js @@ -390,7 +390,6 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen var props; if ( this.props.get('query') ) { props = this.props.toJSON(); - props.cache = ( true !== refresh ); this.mirror( wp.media.model.Query.get( props ) ); } }, diff --git a/src/js/media/models/query.js b/src/js/media/models/query.js index 4a6810adf6..c29a638b10 100644 --- a/src/js/media/models/query.js +++ b/src/js/media/models/query.js @@ -213,7 +213,6 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{ * @method * * @param {object} [props] - * @param {Object} [props.cache=true] Whether to use the query cache or not. * @param {Object} [props.order] * @param {Object} [props.orderby] * @param {Object} [props.include] @@ -243,13 +242,11 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{ var args = {}, orderby = Query.orderby, defaults = Query.defaultProps, - query, - cache = !! props.cache || _.isUndefined( props.cache ); + query; // Remove the `query` property. This isn't linked to a query, // this *is* the query. delete props.query; - delete props.cache; // Fill default args. _.defaults( props, defaults ); @@ -288,14 +285,7 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{ // Substitute exceptions specified in orderby.keymap. args.orderby = orderby.valuemap[ props.orderby ] || props.orderby; - // Search the query cache for a matching query. - if ( cache ) { - query = _.find( queries, function( query ) { - return _.isEqual( query.args, args ); - }); - } else { - queries = []; - } + queries = []; // Otherwise, create a new query and add it to the cache. if ( ! query ) {