Make WordPress Core

Changeset 50029


Ignore:
Timestamp:
01/27/2021 02:49:56 PM (4 years ago)
Author:
antpb
Message:

Media: Reintroduce caching for Media Library query.

In [50021], caching was removed causing unintended classic block media flows to fail.

Reverts [50021].
See #50025.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/media/models/query.js

    r50021 r50029  
    244244                orderby  = Query.orderby,
    245245                defaults = Query.defaultProps,
    246                 query;
     246                query,
     247                cache    = !! props.cache || _.isUndefined( props.cache );
    247248
    248249            // Remove the `query` property. This isn't linked to a query,
    249250            // this *is* the query.
    250251            delete props.query;
     252            delete props.cache;
    251253
    252254            // Fill default args.
     
    287289            args.orderby = orderby.valuemap[ props.orderby ] || props.orderby;
    288290
    289             queries = [];
     291            // Search the query cache for a matching query.
     292            if ( cache ) {
     293                query = _.find( queries, function( query ) {
     294                    return _.isEqual( query.args, args );
     295                });
     296            } else {
     297                queries = [];
     298            }
    290299
    291300            // Otherwise, create a new query and add it to the cache.
Note: See TracChangeset for help on using the changeset viewer.