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 Exception // Undefined index: scope_opener PreGetPostsSniff.php on line 314 #499

Closed
2 tasks
metalandcoffee opened this issue Jul 20, 2020 · 6 comments · Fixed by #565
Closed
2 tasks

Comments

@metalandcoffee
Copy link

Bug Description

The first error that occurs when I lint my functions.php is the following:

An error occurred during processing; checking has been aborted. The error message was: Undefined index: scope_opener in /.../WordPressVIPMinimum/Sniffs/Hooks/PreGetPostsSniff.php on line 314

I'm not sure what is causing this. The linting seems to still continue and the file is error heavy. But I was curious if there was any insight into why this is happening. 🤷🏾‍♀️

Error Code

Internal.Exception

Environment

Use php -v and composer show to get versions.

Question Answer
PHP version 7.2.1
PHP_CodeSniffer version 3.5.5
VIPCS version 2.1.0

Tested Against master branch?

  • I have verified the issue still exists in the master branch of VIPCS.
  • I have verified the issue still exists in the develop branch of VIPCS.
@rebeccahum
Copy link
Contributor

rebeccahum commented Jul 20, 2020

@metalandcoffee Hiya, would we be able to get your copy of functions.php? Also, what happens when you run it via php -l?

@jrfnl
Copy link
Collaborator

jrfnl commented Jul 28, 2020

@metalandcoffee I believe I have a fix for this issue, though I'd still very much would like to see the original code which triggered the error.

In the mean time, it would be awesome if you could test the fix I've pulled in PR #565 and could let us know if that fixes it for you.

@jrfnl jrfnl added this to the 2.2.0 milestone Jul 28, 2020
@metalandcoffee
Copy link
Author

Hi @rebeccahum & @jrfnl !!! I'm sorry for the delay. Here is the functions.php. It's really long so I just attached it as a zip file.
functions.php.zip

I'm going to test the fix now!

@metalandcoffee
Copy link
Author

@jrfnl I'm not getting that error anymore! ✨

@jrfnl
Copy link
Collaborator

jrfnl commented Jul 28, 2020

@metalandcoffee Thanks for testing.

I've had a look at the code and the issue was caused by the inline control structure use, i.e. if () return; without curly braces.

As it is, the sniff would now throw a false positive for your code "Main WP_Query is being modified without $query->is_main_query() check", while the code does actually have a main query check.

Let me see if I can add a quick fix for that too.

@jrfnl
Copy link
Collaborator

jrfnl commented Jul 28, 2020

@metalandcoffee I've updated PR #565 with an additional fix to handle inline control structures better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants