From b7676e4cc8219785523e3c158bd8636cce7b9b9c Mon Sep 17 00:00:00 2001 From: Jellyfrog Date: Mon, 9 Nov 2020 07:28:07 +0100 Subject: [PATCH] Update to Composer 2 (#12263) * Update to Composer 2 No need to roll our own checks anymore since this is now built in. Also limit the update check to once a week. * update * Make Composer wrapper report correct exit code * Update composer_wrapper.php * re-enable extension check Co-authored-by: Tony Murray --- app/Checks.php | 52 ------------------------------------ app/Http/Kernel.php | 7 ----- artisan | 4 ++- bootstrap/autoload.php | 22 --------------- composer.json | 1 + doc/General/Updating.md | 2 +- html/api_v0.php | 2 +- lnms | 2 +- scripts/composer_wrapper.php | 11 +++++--- 9 files changed, 15 insertions(+), 88 deletions(-) delete mode 100644 bootstrap/autoload.php diff --git a/app/Checks.php b/app/Checks.php index 16589c89ef..72349fc992 100644 --- a/app/Checks.php +++ b/app/Checks.php @@ -34,44 +34,6 @@ use Toastr; class Checks { - public static function preAutoload() - { - // Check PHP version otherwise it will just say server error - if (version_compare(PHP_VERSION, '7.3', '<')) { - self::printMessage( - 'PHP version 7.3 or newer is required to run LibreNMS', - null, - true - ); - } - } - - /** - * Pre-boot dependency check - */ - public static function postAutoload() - { - if (! class_exists(\Illuminate\Foundation\Application::class)) { - self::printMessage( - 'Error: Missing dependencies! Run the following command to fix:', - './scripts/composer_wrapper.php install --no-dev', - true - ); - } - } - - public static function preBoot() - { - // check php extensions - if ($missing = self::missingPhpExtensions()) { - self::printMessage( - 'Missing PHP extensions. Please install and enable them on your LibreNMS server.', - $missing, - true - ); - } - } - /** * Post boot Toast messages */ @@ -156,18 +118,4 @@ class Checks exit(1); } } - - private static function missingPhpExtensions() - { - // allow mysqli, but prefer mysqlnd - if (! extension_loaded('mysqlnd') && ! extension_loaded('mysqli')) { - return ['mysqlnd']; - } - - $required_modules = ['mbstring', 'pcre', 'curl', 'xml', 'gd']; - - return array_filter($required_modules, function ($module) { - return ! extension_loaded($module); - }); - } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 14c79cd563..b5021079ec 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -2,7 +2,6 @@ namespace App\Http; -use App\Checks; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel @@ -96,10 +95,4 @@ class Kernel extends HttpKernel \Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Auth\Middleware\Authorize::class, ]; - - public function bootstrap() - { - Checks::preBoot(); - parent::bootstrap(); - } } diff --git a/artisan b/artisan index 44dc07b0e1..5c23e2e24f 100755 --- a/artisan +++ b/artisan @@ -1,6 +1,8 @@ #!/usr/bin/env php 60 * 60 * 24 * 7) { + // self-update + passthru("$exec self-update --quiet --2" . $extra_args); + touch($install_dir . '/composer.phar'); + } } else { $sig_url = ($use_https ? 'https' : 'http') . '://composer.github.io/installer.sig'; @@ -93,7 +97,8 @@ if (! $exec) { } if ($exec) { - passthru("$exec " . implode(' ', array_splice($argv, 1)) . "$extra_args 2>&1"); + passthru("$exec " . implode(' ', array_splice($argv, 1)) . "$extra_args 2>&1", $exit_code); + exit($exit_code); } else { echo "Composer not available, please manually install composer.\n"; }