Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4153951
Add string compression using CompressionStream API for URL Metric pay…
b1ink0 Mar 4, 2025
5347657
Add decompression for REST API request body in URL Metrics endpoint
b1ink0 Mar 4, 2025
29fff3c
Fix failing test
b1ink0 Mar 5, 2025
36bc475
Remove redundant comment and improve doc comment
b1ink0 Mar 6, 2025
a4632d1
Keep XPath for matching the required pattern
b1ink0 Mar 6, 2025
14409a6
Remove `isDebug` conditions and improve JSDoc comments for consistency
b1ink0 Mar 6, 2025
2f81ec0
Add REST API request body decompression and related tests
b1ink0 Mar 6, 2025
90aca14
Add test for `rest_pre_dispatch` hook and cover annotations
b1ink0 Mar 6, 2025
eeb066d
Merge branch 'trunk' into add/url-metrics-compression
b1ink0 Mar 6, 2025
8b84ed3
Suppress unused default export error
westonruter Mar 10, 2025
c59c3ed
Add ext-zlib to composer.json
westonruter Mar 10, 2025
130277a
Switch ext-zlip from require to suggest
westonruter Mar 10, 2025
cbfba12
Run composer update
westonruter Mar 10, 2025
0ca808f
Fix misspelling
westonruter Mar 10, 2025
e1d4b1e
Keep timestamps for URL Metrics current in fixture
westonruter Mar 10, 2025
af1d1dc
Compress URL metrics only when `gzdecode` is available
b1ink0 Mar 12, 2025
97c7836
Merge branch 'trunk' into add/url-metrics-compression
b1ink0 Mar 12, 2025
82fe8e9
Always pass `gzdecodeAvailable` to client
b1ink0 Mar 12, 2025
1984db0
Add max URL metrics size constraints
b1ink0 Mar 13, 2025
5f0be29
Add tests for max URL metrics size filter in REST API
b1ink0 Mar 13, 2025
f9d7fe1
Ensure `od_get_max_url_metric_size` returns a valid positive value wi…
b1ink0 Mar 13, 2025
2a11bf5
Improve DOC comment for filter
b1ink0 Mar 13, 2025
ba383c6
Merge branch 'trunk' of https://github.com/WordPress/performance into…
westonruter Mar 14, 2025
746a410
Use maximum instead of max in PHP; add test coverage
westonruter Mar 14, 2025
d41da3c
Move od_get_maximum_url_metric_size to storage/data.php
westonruter Mar 14, 2025
ad6d264
Fix passing filter name to _doing_it_wrong()
westonruter Mar 14, 2025
c0e3291
Rename string to jsonString to avoid potential type confusion
westonruter Mar 14, 2025
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
Ensure od_get_max_url_metric_size returns a valid positive value wi…
…th fallback

Co-authored-by: Weston Ruter <westonruter@google.com>
  • Loading branch information
b1ink0 and westonruter authored Mar 13, 2025
commit f9d7fe1ab5984d2260b4ca8907981d4f0cc070bb
19 changes: 17 additions & 2 deletions plugins/optimization-detective/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function od_get_asset_path( string $src_path, ?string $min_path = null ): string
* @since n.e.x.t
* @access private
*
* @return int Maximum allowed byte size.
* @return positive-int Maximum allowed byte size.
*/
function od_get_max_url_metric_size(): int {
/**
Expand All @@ -140,5 +140,20 @@ function od_get_max_url_metric_size(): int {
* @param int $max_size Maximum allowed byte size.
* @return int Filtered maximum allowed byte size.
*/
return (int) apply_filters( 'od_max_url_metric_size', MB_IN_BYTES );
$size = (int) apply_filters( 'od_max_url_metric_size', MB_IN_BYTES );
if ( $size <= 0 ) {
_doing_it_wrong(
__FUNCTION__,
esc_html(
sprintf(
/* translators: 1: filter name, 2: size */
__( 'Filter %1$s returned invalid "%2$s". Must be greater than zero.', 'optimization-detective' ),
$size
)
),
''
);
$size = MB_IN_BYTES;
}
return $size;
}