在 Laravel 6 中,任务队列一直运行中的排查分析(由于函数重复定义,PHP 会 发出致命错误(fatal error))
1、参考:在 Linux 、Laravel 6 中,任务队列一直运行中的排查分析(已经设置超时时间):https://www.shuijingwanwq.com/2022/11/10/7139/ 。之前的原因是由于在执行 Artisan::call 时,命令行未返回 1 进而导致判断失效。
2、但是在解决之后,再一次出现了任务队列一直运行中的情况。报错:PHP Fatal error: Cannot redeclare settingUrl() (previously declared in E:\wwwroot\object\Modules\ThemeStoreDB\Resources\setting_migrations\v2.0.23\migrate_settings_data.php:31) in E:\wwwroot\object\Modules\ThemeStoreDB\Resources\setting_migrations\v2.0.23\migrate_cart.php on line 40。如图1
[2022-11-09 16:25:33][x4FpSm3puIKqXniqIAPDSVClo3G8QLNm] Processing: Modules\ThemeStoreDB\Jobs\ThemeInstallationJob PHP Fatal error: Cannot redeclare settingUrl() (previously declared in E:\wwwroot\object\Modules\ThemeStoreDB\Resources\setting_migrations\v2.0.23\migrate_settings_data.php:31) in E:\wwwroot\object\Modules\ThemeStoreDB\Resources\setting_migrations\v2.0.23\migrate_cart.php on line 40 Symfony\Component\Debug\Exception\FatalErrorException : Cannot redeclare settingUrl() (previously declared in E:\wwwroot\object\Modules\ThemeStoreDB\Resources\setting_migrations\v2.0.23\migrate_settings_data.php:31) at E:\wwwroot\object\Modules\ThemeStoreDB\Resources\setting_migrations\v2.0.23\migrate_cart.php:40 36| } 37| } 38| } 39| > 40| function settingUrl($url) 41| { 42| if (is_null($url)) { 43| return null; 44| } Whoops\Exception\ErrorException : Cannot redeclare settingUrl() (previously declared in E:\wwwroot\object\Modules\ThemeStoreDB\Resources\setting_migrations\v2.0.23\migrate_settings_data.php:31) at E:\wwwroot\object\Modules\ThemeStoreDB\Resources\setting_migrations\v2.0.23\migrate_cart.php:40 36| } 37| } 38| } 39| > 40| function settingUrl($url) 41| { 42| if (is_null($url)) { 43| return null; 44| } Exception trace: 1 Whoops\Run::handleError("Cannot redeclare settingUrl() (previously declared in E:\wwwroot\object\Modules\ThemeStoreDB\Resources\setting_migrations\v2.0.23\migrate_settings_data.php:31)", "E:\wwwroot\object\Modules\ThemeStoreDB\Resources\setting_migrations\v2.0.23\migrate_cart.php") E:\wwwroot\object\vendor\filp\whoops\src\Whoops\Run.php:486 2 Whoops\Run::handleShutdown() [internal]:0
3、PHP Fatal error 的原因在于:在 include 所包含的文件中,由于函数重复定义,PHP 会 发出致命错误(fatal error)。
4、最终决定临时的解决方案是将所包含的文件中,重名的函数给修改为不一样的名称,以规避掉此问题。
1 条回复
[…] […]