Skip to content

Commit 6217bdb

Browse files
committed
Merge pull request #2 from WordPress-Coding-Standards/develop
Update Develop from main WPS Fork
2 parents 51806c0 + cd07c76 commit 6217bdb

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

WordPress/Sniffs/VIP/PostsPerPageSniff.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ public function getGroups() {
5050
*/
5151
public function callback( $key, $val, $line, $group ) {
5252
$key = strtolower( $key );
53-
if (
54-
( $key == 'nopaging' && $val == 'true' || $val == 1 )
53+
if (
54+
( $key == 'nopaging' && ( $val == 'true' || $val == 1 ) )
5555
||
5656
( in_array( $key, array( 'numberposts', 'posts_per_page' ) ) && $val == '-1' )
5757
) {
58-
5958
return 'Disabling pagination is prohibited in VIP context, do not set `%s` to `%s` ever.';
6059
}
6160
elseif (

WordPress/Tests/VIP/PostsPerPageUnitTest.inc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ $args = array(
44
'nopaging' => true, // Bad
55
'posts_per_page' => 999, // Bad
66
'posts_per_page' => -1, // Bad
7-
);
7+
'posts_per_page' => 1, // OK
8+
'posts_per_page' => '1', // OK
9+
);
810

911
_query_posts( 'nopaging=true&posts_per_page=999' ); // Bad
1012

1113
$query_args['posts_per_page'] = -1; // Bad
14+
$query_args['posts_per_page'] = 1; // OK
15+
$query_args['posts_per_page'] = '1'; // OK
16+
$query_args['posts_per_page'] = '-1'; // Bad
1217

13-
$query_args['my_posts_per_page'] = -1; // ok
18+
$query_args['my_posts_per_page'] = -1; // OK

WordPress/Tests/VIP/PostsPerPageUnitTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public function getErrorList()
2424
4 => 1,
2525
5 => 1,
2626
6 => 1,
27-
9 => 2,
28-
11 => 1,
27+
11 => 2,
28+
13 => 1,
29+
16 => 1,
2930
);
3031

3132
}//end getErrorList()

0 commit comments

Comments
 (0)