Skip to content

Commit ad6d264

Browse files
committed
Fix passing filter name to _doing_it_wrong()
1 parent d41da3c commit ad6d264

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

plugins/optimization-detective/storage/data.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function od_get_url_metric_freshness_ttl(): int {
3737

3838
if ( $freshness_ttl < 0 ) {
3939
_doing_it_wrong(
40-
__FUNCTION__,
40+
esc_html( "Filter: 'od_url_metric_freshness_ttl'" ),
4141
esc_html(
4242
sprintf(
4343
/* translators: %s is the TTL freshness */
@@ -382,15 +382,13 @@ function od_get_maximum_viewport_aspect_ratio(): float {
382382
* @return positive-int[] Breakpoint max widths, sorted in ascending order.
383383
*/
384384
function od_get_breakpoint_max_widths(): array {
385-
$function_name = __FUNCTION__;
386-
387385
$breakpoint_max_widths = array_map(
388-
static function ( $original_breakpoint ) use ( $function_name ): int {
386+
static function ( $original_breakpoint ): int {
389387
$breakpoint = $original_breakpoint;
390388
if ( $breakpoint <= 0 ) {
391389
$breakpoint = 1;
392390
_doing_it_wrong(
393-
esc_html( $function_name ),
391+
esc_html( "Filter: 'od_breakpoint_max_widths'" ),
394392
esc_html(
395393
sprintf(
396394
/* translators: %s is the actual breakpoint max width */
@@ -447,7 +445,7 @@ function od_get_url_metrics_breakpoint_sample_size(): int {
447445

448446
if ( $sample_size <= 0 ) {
449447
_doing_it_wrong(
450-
__FUNCTION__,
448+
esc_html( "Filter: 'od_url_metrics_breakpoint_sample_size'" ),
451449
esc_html(
452450
sprintf(
453451
/* translators: %s is the sample size */

plugins/optimization-detective/tests/storage/test-data.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ static function (): int {
4848
/**
4949
* Test bad od_get_url_metric_freshness_ttl().
5050
*
51-
* @expectedIncorrectUsage od_get_url_metric_freshness_ttl
5251
* @covers ::od_get_url_metric_freshness_ttl
5352
*/
5453
public function test_bad_od_get_url_metric_freshness_ttl(): void {
54+
$this->setExpectedIncorrectUsage( 'Filter: &#039;od_url_metric_freshness_ttl&#039;' );
5555
add_filter(
5656
'od_url_metric_freshness_ttl',
5757
static function (): int {
@@ -728,13 +728,13 @@ public function data_provider_test_bad_od_get_breakpoint_max_widths(): array {
728728
*
729729
* @covers ::od_get_breakpoint_max_widths
730730
*
731-
* @expectedIncorrectUsage od_get_breakpoint_max_widths
732731
* @dataProvider data_provider_test_bad_od_get_breakpoint_max_widths
733732
*
734733
* @param int[] $breakpoints Breakpoints.
735734
* @param int[] $expected Expected breakpoints.
736735
*/
737736
public function test_bad_od_get_breakpoint_max_widths( array $breakpoints, array $expected ): void {
737+
$this->setExpectedIncorrectUsage( 'Filter: &#039;od_breakpoint_max_widths&#039;' );
738738
add_filter(
739739
'od_breakpoint_max_widths',
740740
static function () use ( $breakpoints ): array {
@@ -766,10 +766,10 @@ static function (): string {
766766
/**
767767
* Test bad od_get_url_metrics_breakpoint_sample_size().
768768
*
769-
* @expectedIncorrectUsage od_get_url_metrics_breakpoint_sample_size
770769
* @covers ::od_get_url_metrics_breakpoint_sample_size
771770
*/
772771
public function test_bad_od_get_url_metrics_breakpoint_sample_size(): void {
772+
$this->setExpectedIncorrectUsage( 'Filter: &#039;od_url_metrics_breakpoint_sample_size&#039;' );
773773
add_filter(
774774
'od_url_metrics_breakpoint_sample_size',
775775
static function (): int {

0 commit comments

Comments
 (0)