Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
60740a8
Factor in IDs of posts in query for computing ETag
ShyamGadde Dec 5, 2024
2239317
Factor in last modified of posts in The Loop
ShyamGadde Dec 5, 2024
3c7842b
Merge logic to get posts in The Loop
ShyamGadde Dec 5, 2024
3c57a1d
Factor in active theme and current template
ShyamGadde Dec 5, 2024
6a5e421
Add missing `@global` tags
ShyamGadde Dec 5, 2024
cc8e252
Add null checks for global variables
ShyamGadde Dec 5, 2024
72f4e54
Add temporary fix for test cases
ShyamGadde Dec 5, 2024
8651d05
Add `queried_object` to ETag data
ShyamGadde Dec 7, 2024
f66012e
Merge branch 'trunk' into update/incorporate-page-state-for-etag
ShyamGadde Dec 7, 2024
56cbe8e
Use dependency injection instead of relying on globals
ShyamGadde Dec 9, 2024
38d0097
Update test_od_get_current_url_metrics_etag
ShyamGadde Dec 9, 2024
d61a8bc
Fix failing test cases due to missing globals
ShyamGadde Dec 9, 2024
072140b
Introduce filter `od_current_url_metrics_etag_active_theme` to improv…
ShyamGadde Dec 9, 2024
4ffb79f
Update test_od_get_current_url_metrics_etag
ShyamGadde Dec 9, 2024
1794cff
Factor in Block Template object
ShyamGadde Dec 9, 2024
3c3a1a3
Merge branch 'trunk' into update/incorporate-page-state-for-etag
ShyamGadde Dec 9, 2024
65dc803
Merge branch 'trunk' into update/incorporate-page-state-for-etag
ShyamGadde Dec 10, 2024
1c0bdac
Remove unnecessary filter `od_current_url_metrics_etag_active_theme`
ShyamGadde Dec 10, 2024
e562726
Merge branch 'trunk' into update/incorporate-page-state-for-etag
ShyamGadde Dec 12, 2024
6d80095
Merge branch 'trunk' into update/incorporate-page-state-for-etag
ShyamGadde Dec 12, 2024
73e4519
Refine `$current_template` assignment logic for block and classic themes
ShyamGadde Dec 12, 2024
59879f0
Update `$current_template` type for static analysis compliance
ShyamGadde Dec 12, 2024
df306e1
Fix indentation
ShyamGadde Dec 12, 2024
c9c0dd8
Move global setup to set_up and cleanup to tear_down
ShyamGadde Dec 12, 2024
4632350
Replace `$GLOBALS` access with explicit global variable declarations
ShyamGadde Dec 12, 2024
5b4e791
Limit queried_object fields to id, type, and last_modified
ShyamGadde Dec 12, 2024
1073780
Use WP_Query method instead of global function for determining post type
ShyamGadde Dec 12, 2024
9a19113
Add isset checks for global variables
ShyamGadde Dec 13, 2024
03d1683
Merge branch 'trunk' into update/incorporate-page-state-for-etag
westonruter Dec 13, 2024
8325cb4
Avoid sleeping in favor of setting an old initial modified time
westonruter Dec 13, 2024
1b3ba00
Reuse post_modified_gmt in queried_object
westonruter Dec 13, 2024
a71fe76
Reuse active theme in test and reduce code duplication
westonruter Dec 14, 2024
03ef8c8
Align post type archive check with other `instanceof` validations
ShyamGadde Dec 14, 2024
73edbdb
Add helper od_get_current_theme_template() function
westonruter Dec 15, 2024
55d56d3
Refactor queried_posts data to have better guaranteed shape
westonruter Dec 15, 2024
63bb613
Avoid adding WP_Block_Template object directly to ETag data in favor …
westonruter Dec 15, 2024
18e0476
Refactor od_get_current_url_metrics_etag to use data provider and add…
westonruter Dec 15, 2024
57a0ba6
Remove unnecessary setting of template global
westonruter Dec 15, 2024
804d71e
Set absolute path to template
westonruter Dec 15, 2024
8fe2f8f
Make additional adjustments to template
westonruter Dec 15, 2024
1869689
Do not rely on WP_Query global being set
westonruter Dec 15, 2024
7c0cfe1
Work around strange user creation issue in factory
westonruter Dec 15, 2024
1fc20af
Add template conditional assertions
westonruter Dec 15, 2024
b083a29
Avoid using pretty permalink for author URL due to GHA testing problem
westonruter Dec 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reuse post_modified_gmt in queried_object
  • Loading branch information
westonruter committed Dec 13, 2024
commit 1b3ba00be4c62c0499bacad7c2d823e7253c02ca
11 changes: 5 additions & 6 deletions plugins/optimization-detective/storage/data.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,14 @@ function od_get_url_metrics_slug( array $query_vars ): string {
function od_get_current_url_metrics_etag( OD_Tag_Visitor_Registry $tag_visitor_registry, WP_Query $wp_query, $current_template ): string {
$queried_object = $wp_query->get_queried_object();
$queried_object_data = array(
'id' => null,
'type' => null,
'last_modified' => null,
'id' => null,
'type' => null,
);

if ( $queried_object instanceof WP_Post ) {
$queried_object_data['id'] = $queried_object->ID;
$queried_object_data['type'] = 'post';
$queried_object_data['last_modified'] = $queried_object->post_modified_gmt;
$queried_object_data['id'] = $queried_object->ID;
$queried_object_data['type'] = 'post';
$queried_object_data['post_modified_gmt'] = $queried_object->post_modified_gmt;
} elseif ( $queried_object instanceof WP_Term ) {
$queried_object_data['id'] = $queried_object->term_id;
$queried_object_data['type'] = 'term';
Expand Down
15 changes: 6 additions & 9 deletions plugins/optimization-detective/tests/storage/test-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,8 @@ static function ( $data ) {
array(
'tag_visitors' => array(),
'queried_object' => array(
'id' => null,
'type' => null,
'last_modified' => null,
'id' => null,
'type' => null,
),
'queried_posts' => wp_list_pluck( $wp_the_query->posts, 'post_modified_gmt', 'ID' ),
'active_theme' => array(
Expand Down Expand Up @@ -394,9 +393,8 @@ static function ( $data ) {
array(
'tag_visitors' => array( 'foo', 'bar', 'baz' ),
'queried_object' => array(
'id' => null,
'type' => null,
'last_modified' => null,
'id' => null,
'type' => null,
),
'queried_posts' => wp_list_pluck( $wp_the_query->posts, 'post_modified_gmt', 'ID' ),
'active_theme' => array(
Expand Down Expand Up @@ -430,9 +428,8 @@ static function ( $data ) {
array(
'tag_visitors' => array( 'foo', 'bar', 'baz' ),
'queried_object' => array(
'id' => null,
'type' => null,
'last_modified' => null,
'id' => null,
'type' => null,
),
'queried_posts' => wp_list_pluck( $wp_the_query->posts, 'post_modified_gmt', 'ID' ),
'active_theme' => array(
Expand Down