Changes between Version 4 and Version 5 of Ticket #59516, comment 10
- Timestamp:
- 10/24/2023 02:23:41 PM (16 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #59516, comment 10
v4 v5 30 30 31 31 == 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]) 32 The key is build using args only. However none of the args is used to modify the output after query is fired and before caching. 33 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]) 33 34 34 35 == WP_Site_Query … … 46 47 **Step 2: Use only those key from** 47 48 We 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.49 For 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). 49 50 For 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`. 50 51