Media: Reintroduce caching for Media Library query.
In [50021], caching was removed causing unintended classic block media flows to fail. Reverts [50021]. See #50025. Built from https://develop.svn.wordpress.org/trunk@50029 git-svn-id: http://core.svn.wordpress.org/trunk@49730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
401b0bbe8c
commit
d7e0ddebd1
|
@ -1328,11 +1328,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 );
|
||||
|
@ -1371,7 +1373,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 ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.7-alpha-50028';
|
||||
$wp_version = '5.7-alpha-50029';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue