mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 06:00:55 +08:00
When we use `php artisan optimize` command, it will cause duplicate includes:
```
PHP Fatal error: Cannot redeclare function get_global_sp_state() (previously declared in include/globalfunctions.php:3) in include/globalfunctions.php on line 3
Symfony\Component\ErrorHandler\Error\FatalError
Cannot redeclare function get_global_sp_state() (previously declared in include/globalfunctions.php:3)
at include/globalfunctions.php:3
1▕ <?php
2▕
➜ 3▕ function get_global_sp_state()
4▕ {
5▕ static $global_promotion_state;
6▕ $cacheKey = \App\Models\Setting::TORRENT_GLOBAL_STATE_CACHE_KEY;
7▕ if (is_null($global_promotion_state)) {
8▕ $row = \Nexus\Database\NexusDB::remember($cacheKey, 600, function () use ($cacheKey) {
9▕ return \Nexus\Database\NexusDB::getOne('torrents_state', 1);
Whoops\Exception\ErrorException
Cannot redeclare function get_global_sp_state() (previously declared in include/globalfunctions.php:3)
at include/globalfunctions.php:3
1▕ <?php
2▕
➜ 3▕ function get_global_sp_state()
4▕ {
5▕ static $global_promotion_state;
6▕ $cacheKey = \App\Models\Setting::TORRENT_GLOBAL_STATE_CACHE_KEY;
7▕ if (is_null($global_promotion_state)) {
8▕ $row = \Nexus\Database\NexusDB::remember($cacheKey, 600, function () use ($cacheKey) {
9▕ return \Nexus\Database\NexusDB::getOne('torrents_state', 1);
+1 vendor frames
2 [internal]:0
Whoops\Run::handleShutdown()
```
So we should use `require_once` instead of `require` to avoid this issue.
Signed-off-by: Qi HU <github@spcsky.com>