Fatal Error on v 1.5.0 during scans
mindctrl opened this issue · 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
Similar errors reported here: https://wordpress.org/support/topic/fatal-error-created-by-plugin/
Similar errors reported here: https://wordpress.org/support/topic/fatal-error-created-by-plugin/
Confirming version 1.5.0 causes fatal error. Checked, version 1.4.7 doesn't cause these issues.
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 It should not be fixed like that. This should be fixed by making sure all relevant vendor
files are included with the plugin.
@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 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.
Sorry about my ignorance, but how would you do that?
"update to PHPCompatibilityWP 2.1.0 in combination with PHPCompatibility 9.3.1"
Thanks
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 ?
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 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 But currently with this Fatal error it seem unusable? Am I correct?
@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