mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Media: Reintroduce caching for Media Library query.
In [50021], caching was removed causing unintended classic block media flows to fail. Reverts [50021]. See #50025. git-svn-id: https://develop.svn.wordpress.org/trunk@50029 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -243,11 +243,13 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
|
||||
var args = {},
|
||||
orderby = Query.orderby,
|
||||
defaults = Query.defaultProps,
|
||||
query;
|
||||
query,
|
||||
cache = !! props.cache || _.isUndefined( props.cache );
|
||||
|
||||
// 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 );
|
||||
@@ -286,7 +288,14 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
|
||||
// Substitute exceptions specified in orderby.keymap.
|
||||
args.orderby = orderby.valuemap[ props.orderby ] || props.orderby;
|
||||
|
||||
queries = [];
|
||||
// Search the query cache for a matching query.
|
||||
if ( cache ) {
|
||||
query = _.find( queries, function( query ) {
|
||||
return _.isEqual( query.args, args );
|
||||
});
|
||||
} else {
|
||||
queries = [];
|
||||
}
|
||||
|
||||
// Otherwise, create a new query and add it to the cache.
|
||||
if ( ! query ) {
|
||||
|
||||
Reference in New Issue
Block a user