Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal error in WordPress/Sniffs/WP/PostsPerPageSniff.php #2390

Closed
1 task done
anomiex opened this issue Sep 14, 2023 · 1 comment · Fixed by #2392
Closed
1 task done

Internal error in WordPress/Sniffs/WP/PostsPerPageSniff.php #2390

anomiex opened this issue Sep 14, 2023 · 1 comment · Fixed by #2392
Milestone

Comments

@anomiex
Copy link
Contributor

anomiex commented Sep 14, 2023

Bug Description

This code fails if the $val is an empty string.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | An error occurred during processing; checking has been aborted. The error message was: Uninitialized string offset 0 in /tmp/test/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/PostsPerPageSniff.php on line
   |       | 81 (Internal.Exception)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Minimal Code Snippet

The issue happens when running this command:

vendor/bin/phpcs -s --standard=WordPress --sniffs=WordPress.WP.PostsPerPage test.php

... over a file containing this code:

<?php

$query = 'posts_per_page=' . (int) $_POST['limit'];

Error Code

WordPress.WP.PostsPerPage

Environment

Question Answer
PHP version 8.2.10
PHP_CodeSniffer version 3.7.2
WordPressCS version dev-develop e02529f, also tried with 3.0.1
PHPCSUtils version 1.0.8
PHPCSExtra version 1.1.1
WordPressCS install type Composer project local
IDE (if relevant) None

Additional Context (optional)

Tested Against develop Branch?

  • I have verified the issue still exists in the develop branch of WordPressCS.
@jrfnl
Copy link
Member

jrfnl commented Sep 19, 2023

Thanks for reporting this @anomiex !

@jrfnl jrfnl modified the milestones: 3.x Next, 3.1.0 Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants