From ffc2cc5617b9834e1862abd43133b66bca9b88df Mon Sep 17 00:00:00 2001 From: antpb Date: Fri, 29 Jan 2021 01:35:59 +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. Built from https://develop.svn.wordpress.org/trunk@50067 git-svn-id: http://core.svn.wordpress.org/trunk@49768 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/media-models.js | 15 ++------------- wp-includes/js/media-models.min.js | 2 +- wp-includes/version.php | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/wp-includes/js/media-models.js b/wp-includes/js/media-models.js index dd383ed5a6..9fb7f65070 100644 --- a/wp-includes/js/media-models.js +++ b/wp-includes/js/media-models.js @@ -916,7 +916,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 ) ); } }, @@ -1298,7 +1297,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] @@ -1328,13 +1326,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 ); @@ -1373,14 +1369,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 ) { diff --git a/wp-includes/js/media-models.min.js b/wp-includes/js/media-models.min.js index 5d0249ee1b..c625a1679c 100644 --- a/wp-includes/js/media-models.min.js +++ b/wp-includes/js/media-models.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(i){var s={};function r(t){if(s[t])return s[t].exports;var e=s[t]={i:t,l:!1,exports:{}};return i[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}r.m=i,r.c=s,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)r.d(i,s,function(t){return e[t]}.bind(null,s));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=22)}({22:function(t,e,i){t.exports=i(23)},23:function(t,e,i){var s,r,n,a,o=jQuery;window.wp=window.wp||{},a=wp.media=function(t){var e,i=a.view.MediaFrame;if(i)return"select"===(t=_.defaults(t||{},{frame:"select"})).frame&&i.Select?e=new i.Select(t):"post"===t.frame&&i.Post?e=new i.Post(t):"manage"===t.frame&&i.Manage?e=new i.Manage(t):"image"===t.frame&&i.ImageDetails?e=new i.ImageDetails(t):"audio"===t.frame&&i.AudioDetails?e=new i.AudioDetails(t):"video"===t.frame&&i.VideoDetails?e=new i.VideoDetails(t):"edit-attachments"===t.frame&&i.EditAttachments&&(e=new i.EditAttachments(t)),delete t.frame,a.frame=e},_.extend(a,{model:{},view:{},controller:{},frames:{}}),n=a.model.l10n=window._wpMediaModelsL10n||{},a.model.settings=n.settings||{},delete n.settings,s=a.model.Attachment=i(24),r=a.model.Attachments=i(25),a.model.Query=i(26),a.model.PostImage=i(27),a.model.Selection=i(28),a.compare=function(t,e,i,s){return _.isEqual(t,e)?i===s?0:s=this.created)},i=["s","order","orderby","posts_per_page","post_mime_type","post_parent","author"],wp.Uploader&&_(this.args).chain().keys().difference(i).isEmpty().value()&&this.observe(wp.Uploader.queue)},hasMore:function(){return this._hasMore},more:function(t){var e=this;return this._more&&"pending"===this._more.state()?this._more:this.hasMore()?((t=t||{}).remove=!1,this._more=this.fetch(t).done(function(t){(_.isEmpty(t)||-1===this.args.posts_per_page||t.length=this.created)},i=["s","order","orderby","posts_per_page","post_mime_type","post_parent","author"],wp.Uploader&&_(this.args).chain().keys().difference(i).isEmpty().value()&&this.observe(wp.Uploader.queue)},hasMore:function(){return this._hasMore},more:function(t){var e=this;return this._more&&"pending"===this._more.state()?this._more:this.hasMore()?((t=t||{}).remove=!1,this._more=this.fetch(t).done(function(t){(_.isEmpty(t)||-1===this.args.posts_per_page||t.length