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:
antpb 2021-01-27 14:51:00 +00:00
parent 401b0bbe8c
commit d7e0ddebd1
3 changed files with 13 additions and 4 deletions

View File

@ -1328,11 +1328,13 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
var args = {}, var args = {},
orderby = Query.orderby, orderby = Query.orderby,
defaults = Query.defaultProps, defaults = Query.defaultProps,
query; query,
cache = !! props.cache || _.isUndefined( props.cache );
// Remove the `query` property. This isn't linked to a query, // Remove the `query` property. This isn't linked to a query,
// this *is* the query. // this *is* the query.
delete props.query; delete props.query;
delete props.cache;
// Fill default args. // Fill default args.
_.defaults( props, defaults ); _.defaults( props, defaults );
@ -1371,7 +1373,14 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
// Substitute exceptions specified in orderby.keymap. // Substitute exceptions specified in orderby.keymap.
args.orderby = orderby.valuemap[ props.orderby ] || props.orderby; 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. // Otherwise, create a new query and add it to the cache.
if ( ! query ) { if ( ! query ) {

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.