Make WordPress Core

Changes between Version 4 and Version 5 of Ticket #59516, comment 10


Ignore:
Timestamp:
10/24/2023 02:23:41 PM (9 months ago)
Author:
thekt12
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #59516, comment 10

    v4 v5  
    3030
    3131== WP_Network_Query
    32 The key is entirely based on args,  however none of the args affect the outcome post query is fired. So we could modify the code to be more like WP_Query with a separate function for generate_key based on the request and args or just the args. ([https://github.com/WordPress/wordpress-develop/blob/781953641607c4d5b0743a6924af0e820fd54871/src/wp-includes/class-wp-network-query.php#L249 code])
     32The key is build using args only. However none of the args is used to modify the output after query is fired and before caching.
     33So we could modify the code to be more like WP_Query with a separate function for generate_key based on the request and args or just the args. ([https://github.com/WordPress/wordpress-develop/blob/781953641607c4d5b0743a6924af0e820fd54871/src/wp-includes/class-wp-network-query.php#L249 code])
    3334
    3435== WP_Site_Query
     
    4647**Step 2: Use only those key from**
    4748We should only pass the args (filter it before) to `generate_cache_key()` for cache key generation that effects the way cache is done (Detailed in the Findings section above).
    48 For filtering have a array of filed that needs to be considered in an array and only scrap out those args from the main args.
     49For filtering, we can have an array keys that needs to be considered in an array and only scrap out those keys from the main args ($q).
    4950For e.g `$key_to_consider = array( ‘fields’ )` for WP_Query, we can provide a filter which will allow third parties to add more keys that should be considered, extra care must be given not to unset key from the original `$args`.
    5051