mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
fix: Fix duplicate includes in app.php
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>
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('LARAVEL_START') || define('LARAVEL_START', microtime(true));
|
defined('LARAVEL_START') || define('LARAVEL_START', microtime(true));
|
||||||
defined('IN_NEXUS') || define('IN_NEXUS', false);
|
defined('IN_NEXUS') || define('IN_NEXUS', false);
|
||||||
require dirname(__DIR__) . '/include/constants.php';
|
require_once dirname(__DIR__) . '/include/constants.php';
|
||||||
require dirname(__DIR__) . '/include/globalfunctions.php';
|
require_once dirname(__DIR__) . '/include/globalfunctions.php';
|
||||||
require dirname(__DIR__) . '/include/functions.php';
|
require_once dirname(__DIR__) . '/include/functions.php';
|
||||||
if (!RUNNING_IN_OCTANE) {
|
if (!RUNNING_IN_OCTANE) {
|
||||||
\Nexus\Nexus::boot();
|
\Nexus\Nexus::boot();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user