没有不值得去解决的问题,也没有不值得去学习的技术!

Debugging a Continuously Running Job Queue in Laravel 6: A Fatal Error Caused by Duplicate Function Definitions

The job queue got stuck in a running state once again. Error reported: PHP Fatal error: Cannot redeclare settingUrl() (previously declared in

1. Reference: Troubleshooting analysis of a Laravel 6 job queue stuck in a running state on Linux (timeout already set). The previous cause was that executing Artisan::call did not return 1 from the command line, which led to the condition check failing.

2. However, after resolving that, the job queue got stuck in a running state once again. The error reported was: 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. See Figure 1.

The job queue got stuck in a running state once again. Error reported: PHP Fatal error: Cannot redeclare settingUrl() (previously declared in
Figure 1
Plaintext

[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. The cause of the PHP Fatal error is that within the files included via include, a function is defined more than once, which causes PHP to emit a fatal error.

4. The final temporary workaround is to rename the duplicate functions in the included files to different names to avoid this issue.

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系