Skip to content

Commit 75195f8

Browse files
committed
user helper to ensure upper and lower bounds
1 parent e6d5ea9 commit 75195f8

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

concat-utils.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
}
66

77
class WPCOM_Concat_Utils {
8+
9+
public static function get_concat_max() {
10+
// no less than 10, no more than 150
11+
return min( max( intval( VIP_CONCAT_MAX ), 10 ), 150 );
12+
}
13+
814
public static function is_internal_url( $test_url, $site_url ) {
915
$test_url_parsed = parse_url( is_string( $test_url ) ? $test_url : '' );
1016
$site_url_parsed = parse_url( $site_url );

cssconcat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function do_items( $handles = false, $group = false ) {
9999

100100
$stylesheets[ $stylesheet_group_index ][ $media ][ $handle ] = $css_url_parsed['path'];
101101

102-
if ( count( $stylesheets[ $stylesheet_group_index ][ $media ] ) >= VIP_CONCAT_MAX ) {
102+
if ( count( $stylesheets[ $stylesheet_group_index ][ $media ] ) >= WPCOM_Concat_Utils::get_concat_max() ) {
103103
$stylesheet_group_index++;
104104
}
105105
$this->done[] = $handle;

jsconcat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function do_items( $handles = false, $group = false ) {
129129
$javascripts[$level]['paths'][] = $js_url_parsed['path'];
130130
$javascripts[$level]['handles'][] = $handle;
131131

132-
if ( count( $javascripts[$level]['paths'] ) >= VIP_CONCAT_MAX ) {
132+
if ( count( $javascripts[$level]['paths'] ) >= WPCOM_Concat_Utils::get_concat_max() ) {
133133
$level++;
134134
}
135135

ngx-http-concat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function concat_get_path( $uri ) {
113113
concat_http_status_exit( 400 );
114114

115115
// array( '/foo/bar.css', '/foo1/bar/baz.css' )
116-
if ( 0 == count( $args ) || count( $args ) > VIP_CONCAT_MAX )
116+
if ( 0 == count( $args ) || count( $args ) > WPCOM_Concat_Utils::get_concat_max() )
117117
concat_http_status_exit( 400 );
118118

119119
// If we're in a subdirectory context, use that as the root.

0 commit comments

Comments
 (0)