Add more specific filters for modifying surrogate keys in different contexts#109
Add more specific filters for modifying surrogate keys in different contexts#109danielbachhuber merged 8 commits intopantheon-systems:masterfrom rubas:purge_filters
Conversation
danielbachhuber
left a comment
There was a problem hiding this comment.
👍 Good idea generally. Left a few comments to address.
pantheon-advanced-page-cache.php
Outdated
| */ | ||
| function pantheon_wp_clear_edge_keys( $keys ) { | ||
| $keys = array_unique( $keys ); | ||
| $keys = \Pantheon_Advanced_Page_Cache\Emitter::filter_huge_surrogate_keys_list( $keys ); |
There was a problem hiding this comment.
Why are you calling filter_huge_surrogate_keys_list() in this context?
There was a problem hiding this comment.
I'm not sure, if Pantheon purges the keys with Header or JSON post body.
But after double checking the Fastly Documentation, it would be better to check for max 256 keys instead of const HEADER_MAX_LENGTH = 32512 assuming they purge via JSON post body.
There was a problem hiding this comment.
@rubas Oh, we can remove. Pantheon has middleware to safely handle large lists of keys.
Do you want to finish up this PR or shall I?
There was a problem hiding this comment.
Do you want to finish up this PR or shall I?
Nevermind, just saw your other comments. We can land this today, and then I'll tag a release on Monday.
There was a problem hiding this comment.
Pantheon has middleware to safely handle large lists of keys.
👍
Do you want to finish up this PR or shall I?
Happy to hand it over. Otherwise I'll have a look at it this weekend.
| public static function action_clean_term_cache( $term_ids ) { | ||
| $keys = array(); | ||
| $term_ids = is_array( $term_ids ) ? $term_ids : array( $term_id ); | ||
| $term_ids = is_array( $term_ids ) ? $term_ids : array( $term_ids ); |
There was a problem hiding this comment.
Can you remove this from the PR please?
inc/class-purger.php
Outdated
| return; | ||
| } | ||
| pantheon_wp_clear_edge_keys( array( 'post-' . $post_id, 'rest-post-' . $post_id, 'post-huge', 'rest-post-huge' ) ); | ||
| $keys = apply_filters( 'pantheon_purge_clean_post_cache', array( 'post-' . $post_id, 'rest-post-' . $post_id, 'post-huge', 'rest-post-huge' ), $post_id ); |
There was a problem hiding this comment.
For each filter, can you make sure you're indenting with tabs, not spaces, and add the appropriate doc block?
Having filter hooks allows for a cleaner extension.