phpcompat icon indicating copy to clipboard operation
phpcompat copied to clipboard

Fatal Error on v 1.5.0 during scans

Open mindctrl opened this issue 6 years ago • 13 comments

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 avatar Aug 05 '19 14:08 mindctrl

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

mindctrl avatar Aug 13 '19 18:08 mindctrl

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

@shawnhooper

stevenkword avatar Aug 13 '19 19:08 stevenkword

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

bluestarstudios avatar Aug 24 '19 06:08 bluestarstudios

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 );

TimSmith avatar Sep 27 '19 14:09 TimSmith

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

jrfnl avatar Sep 27 '19 14:09 jrfnl

@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.

TimSmith avatar Sep 27 '19 15:09 TimSmith

@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.

jrfnl avatar Sep 27 '19 15:09 jrfnl

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

tatuiot avatar Mar 24 '20 13:03 tatuiot

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 ?

jrfnl avatar Mar 24 '20 13:03 jrfnl

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..

ehausen avatar Oct 15 '20 08:10 ehausen

@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.

jrfnl avatar Oct 15 '20 10:10 jrfnl

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

ehausen avatar Oct 15 '20 10:10 ehausen

@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

jrfnl avatar Oct 15 '20 11:10 jrfnl