Skip to content

Commit f64e4ab

Browse files
committed
Simplify logic to ensure -1 <= limit_per_type <= PHP_INT_MAX
1 parent 035e99c commit f64e4ab

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/Validation/URLScanningContext.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,7 @@ public function get_limit_per_type() {
8080
*/
8181
$url_validation_limit_per_type = (int) apply_filters( 'amp_url_validation_limit_per_type', $this->limit_per_type );
8282

83-
// Valid values are any integer -1 and above.
84-
if ( $url_validation_limit_per_type < -1 ) {
85-
$url_validation_limit_per_type = 1;
86-
}
87-
88-
return $url_validation_limit_per_type;
83+
return max( $url_validation_limit_per_type, -1 );
8984
}
9085

9186
/**

tests/php/src/Validation/URLScanningContextTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static function() {
4444
return -4;
4545
}
4646
);
47-
$this->assertEquals( 1, $this->test_instance->get_limit_per_type() );
47+
$this->assertEquals( -1, $this->test_instance->get_limit_per_type() );
4848

4949
add_filter(
5050
'amp_url_validation_limit_per_type',

0 commit comments

Comments
 (0)