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

Fatal Error on v 1.5.0 during scans #245

Open
mindctrl opened this issue Aug 5, 2019 · 13 comments · Fixed by #307
Open

Fatal Error on v 1.5.0 during scans #245

mindctrl opened this issue Aug 5, 2019 · 13 comments · Fixed by #307

Comments

@mindctrl
Copy link

mindctrl commented Aug 5, 2019

When scanning the plugin triggers PHP fatal errors due to missing methods in some of the dependencies. This happens via WP-CLI or the UI.

I haven't dug deeply into this, but it appears the composer dependencies weren't fully updated/included, as some of the code calls methods that aren't in the build.

@stevenkword pinging you for visibility.

wp phpcompat 7.3 --scan=all
Testing compatibility with PHP 7.3.

PHP Fatal error:  Uncaught Error: Call to undefined method PHPCompatibility\PHPCSHelper::findStartOfStatement() in /wp-content/plugins/php-compatibility-checker/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/ArgumentFunctionsReportCurrentValueSniff.php:323
Stack trace:
#0 /wp-content/plugins/php-compatibility-checker/vendor/squizlabs/php_codesniffer/CodeSniffer/File.php(576): PHPCompatibility\Sniffs\FunctionUse\ArgumentFunctionsReportCurrentValueSniff->process(Object(PHP_CodeSniffer_File), 1294)
#1 /wp-content/plugins/php-compatibility-checker/vendor/squizlabs/php_codesniffer/CodeSniffer.php(1894): PHP_CodeSniffer_File->start(NULL)
#2 /wp-content/plugins/php-compatibility-checker/vendor/squizlabs/php_codesniffer/CodeSniffer.php(1772): PHP_CodeSniffer->_processFile('/srv/www/jp.com...', NULL)
#3 /wp-content/plugins/php-compatibility-checker/vendor/squizlabs/php_cod in /wp-content/plugins/php-compatibility-checker/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/ArgumentFunctionsReportCurrentValueSniff.php on line 323
PHP Fatal error:  Uncaught Error: Call to undefined method PHPCompatibility\Sniffs\Operators\RemovedTernaryAssociativitySniff::isShortTernary() in /wp-content/plugins/php-compatibility-checker/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Operators/RemovedTernaryAssociativitySniff.php:125
Stack trace:
#0 /wp-content/plugins/php-compatibility-checker/vendor/squizlabs/php_codesniffer/CodeSniffer/File.php(576): PHPCompatibility\Sniffs\Operators\RemovedTernaryAssociativitySniff->process(Object(PHP_CodeSniffer_File), 568)
#1 /wp-content/plugins/php-compatibility-checker/vendor/squizlabs/php_codesniffer/CodeSniffer.php(1894): PHP_CodeSniffer_File->start(NULL)
#2 /wp-content/plugins/php-compatibility-checker/vendor/squizlabs/php_codesniffer/CodeSniffer.php(1772): PHP_CodeSniffer->_processFile('/srv/www/jp.com...', NULL)
#3 /wp-content/plugins/php-compatibility-checker/vendor/squizl in /wp-content/plugins/php-compatibility-checker/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Operators/RemovedTernaryAssociativitySniff.php on line 125
@mindctrl mindctrl added the bug label Aug 5, 2019
@mindctrl
Copy link
Author

Similar errors reported here: https://wordpress.org/support/topic/fatal-error-created-by-plugin/

@stevenkword
Copy link

@bluestarstudios
Copy link

Confirming version 1.5.0 causes fatal error. Checked, version 1.4.7 doesn't cause these issues.

@TimSmith
Copy link

Re: PHP Fatal error: Uncaught Error: Call to undefined method PHPCompatibility\PHPCSHelper::findStartOfStatement() in /wp-content/plugins/php-compatibility-checker/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/ArgumentFunctionsReportCurrentValueSniff.php:323)

This particular error can be fixed by changing the offending line 323 to
$startOfStatement = $phpcsFile->findStartOfStatement( $i, $this->ignoreForStartOfStatement );

@jrfnl
Copy link

jrfnl commented Sep 27, 2019

@TimSmith It should not be fixed like that. This should be fixed by making sure all relevant vendor files are included with the plugin.

@TimSmith
Copy link

@jrfnl The root problem is that the PHPCompatibility vendor files in the plugin are using the PHPCompatibility version 8.2.0 codebase but with the Sniffs taken from version 9.2.0.

My 'fix' is just a sticking plaster that let me execute the plugin immediately.

@jrfnl
Copy link

jrfnl commented Sep 27, 2019

@TimSmith That's what I mean, the vendor directory in the plugin wasn't updated correctly for the 1.5.0 release and this needs to be fixed.

An update to PHPCompatibilityWP 2.1.0 in combination with PHPCompatibility 9.3.1 would be good too to catch a lot more PHP 7.4 issues.

@tatuiot
Copy link

tatuiot commented Mar 24, 2020

Sorry about my ignorance, but how would you do that?
"update to PHPCompatibilityWP 2.1.0 in combination with PHPCompatibility 9.3.1"
Thanks

@jrfnl
Copy link

jrfnl commented Mar 24, 2020

Sorry about my ignorance, but how would you do that?

@tatuiot Are you asking cause you want to create a fix ? or because you want to "fix" this for your own WP install only ?

@ehausen
Copy link

ehausen commented Oct 15, 2020

Would rolling back to 1.4.7 be pretty okay, to be able to use the module?

Does the check still finish despite this error? Fatal would indicate that it interrupts the scan..

@jrfnl
Copy link

jrfnl commented Oct 15, 2020

@ehausen Rolling back will mean the scans being run will be not be up to date, i.e. a lot of issues won't be caught and reported.

@ehausen
Copy link

ehausen commented Oct 15, 2020

@jrfnl But currently with this Fatal error it seem unusable? Am I correct?

@jrfnl
Copy link

jrfnl commented Oct 15, 2020

@ehausen Yes, fatal errors break things. Not sure what your usecase is, but you could just use the underlying tooling directly: https://github.com/PHPCompatibility/PHPCompatibility

@jeffpaul jeffpaul linked a pull request Jul 25, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants