Laravel 导致 PHP 警告(未捕获异常)启用 xdebug,否则一切正常
Laravel causes PHP warning (exception not caught) xdebug enabled, otherwise all is fine
启用 xdebug 后我可以重现错误:
composer create-project laravel/laravel
cd laravel
composer require proengsoft/laravel-jsvalidation
php artisan vendor:publish --provider="Proengsoft\JsValidation\JsValidationServiceProvider" --tag=public
错误:
PHP Warning: Uncaught League\Flysystem\Plugin\PluginNotFoundException: Plugin not found for method: read in /tmp/laravel/vendor/league/flysystem/src/Plugin/PluggableTrait.php:49
堆栈跟踪:
但是没有启用 xdebug,一切运行正常。
在向 xdebug 报告之前,我想知道这是否只发生在我身上或也发生在其他人身上。
php -v
PHP 7.1.15-1+ubuntu16.04.1+deb.sury.org+2
Package: php-xdebug
Version: 2.6.0+2.5.5-1+ubuntu16.04.1+deb.sury.org+1
Composer.lock供参考
https://gist.github.com/amenk/9d63975cf4aabf86288b79fb95e8156c
我在 Flysystem 中追踪到以下函数:
public function invokePluginOnFilesystem($method, $arguments, $prefix)
{
$filesystem = $this->getFilesystem($prefix);
try {
return $this->invokePlugin($method, $arguments, $filesystem);
} catch (PluginNotFoundException $e) {
// Let it pass, it's ok, don't panic.
}
$callback = [$filesystem, $method];
return call_user_func_array($callback, $arguments);
}
异常在 invokePlugin() 中抛出,但在事后被捕获(如果 xdebug 关闭)。它打开了 Xdebug,它不再起作用了。
我对 PHP-CLI 有 1G 的内存限制。
这不是真正的问题,而是错误报告。由于异常,我可以轻松地重现各种不稳定的情况。请在 https://bugs.xdebug.org 提交错误报告 — 最好使用更小的测试用例
更多信息/快速修复:
我正在使用
xdebug.collect_params=4
和
xdebug.collect_params=1
没有出现bug。
此外,该错误仅在更新到 PHP 7.1.15 后出现 - 而在 PHP 7.2
中则不会出现
文档中也有关于大脚本的警告:
https://xdebug.org/docs/all_settings
The setting defaults to 0 because for very large scripts it may use
huge amounts of memory and therefore make it impossible for the huge
script to run. You can most safely turn this setting on, but you can
expect some problems in scripts with a lot of function calls and/or
huge data structures as parameters. Xdebug 2 will not have this
problem with increased memory usage, as it will never store this
information in memory. Instead it will only be written to disk. This
means that you need to have a look at the disk usage though.
启用 xdebug 后我可以重现错误:
composer create-project laravel/laravel
cd laravel
composer require proengsoft/laravel-jsvalidation
php artisan vendor:publish --provider="Proengsoft\JsValidation\JsValidationServiceProvider" --tag=public
错误:
PHP Warning: Uncaught League\Flysystem\Plugin\PluginNotFoundException: Plugin not found for method: read in /tmp/laravel/vendor/league/flysystem/src/Plugin/PluggableTrait.php:49
堆栈跟踪:
但是没有启用 xdebug,一切运行正常。
在向 xdebug 报告之前,我想知道这是否只发生在我身上或也发生在其他人身上。
php -v
PHP 7.1.15-1+ubuntu16.04.1+deb.sury.org+2
Package: php-xdebug
Version: 2.6.0+2.5.5-1+ubuntu16.04.1+deb.sury.org+1
Composer.lock供参考
https://gist.github.com/amenk/9d63975cf4aabf86288b79fb95e8156c
我在 Flysystem 中追踪到以下函数:
public function invokePluginOnFilesystem($method, $arguments, $prefix)
{
$filesystem = $this->getFilesystem($prefix);
try {
return $this->invokePlugin($method, $arguments, $filesystem);
} catch (PluginNotFoundException $e) {
// Let it pass, it's ok, don't panic.
}
$callback = [$filesystem, $method];
return call_user_func_array($callback, $arguments);
}
异常在 invokePlugin() 中抛出,但在事后被捕获(如果 xdebug 关闭)。它打开了 Xdebug,它不再起作用了。
我对 PHP-CLI 有 1G 的内存限制。
这不是真正的问题,而是错误报告。由于异常,我可以轻松地重现各种不稳定的情况。请在 https://bugs.xdebug.org 提交错误报告 — 最好使用更小的测试用例
更多信息/快速修复:
我正在使用
xdebug.collect_params=4
和
xdebug.collect_params=1
没有出现bug。
此外,该错误仅在更新到 PHP 7.1.15 后出现 - 而在 PHP 7.2
中则不会出现文档中也有关于大脚本的警告:
https://xdebug.org/docs/all_settings
The setting defaults to 0 because for very large scripts it may use huge amounts of memory and therefore make it impossible for the huge script to run. You can most safely turn this setting on, but you can expect some problems in scripts with a lot of function calls and/or huge data structures as parameters. Xdebug 2 will not have this problem with increased memory usage, as it will never store this information in memory. Instead it will only be written to disk. This means that you need to have a look at the disk usage though.