diff --git a/LibreNMS/Config.php b/LibreNMS/Config.php index 39c70abc30..ed68d2dab8 100644 --- a/LibreNMS/Config.php +++ b/LibreNMS/Config.php @@ -31,7 +31,6 @@ use Illuminate\Database\QueryException; use Illuminate\Support\Arr; use Illuminate\Support\Str; use LibreNMS\Data\Store\Rrd; -use LibreNMS\DB\Eloquent; use LibreNMS\Util\Debug; use LibreNMS\Util\Version; use Log; @@ -254,11 +253,11 @@ class Config public static function persist($key, $value) { try { + Arr::set(self::$config, $key, $value); \App\Models\Config::updateOrCreate(['config_name' => $key], [ 'config_name' => $key, 'config_value' => $value, ]); - Arr::set(self::$config, $key, $value); // delete any children (there should not be any unless it is legacy) \App\Models\Config::query()->where('config_name', 'like', "$key.%")->delete(); @@ -338,10 +337,6 @@ class Config */ private static function loadDB() { - if (! Eloquent::isConnected()) { - return; - } - try { \App\Models\Config::get(['config_name', 'config_value']) ->each(function ($item) { @@ -462,15 +457,10 @@ class Config self::persist('device_display_default', $display_value); } - $persist = Eloquent::isConnected(); // make sure we have full path to binaries in case PATH isn't set foreach (['fping', 'fping6', 'snmpgetnext', 'rrdtool', 'traceroute', 'traceroute6'] as $bin) { if (! is_executable(self::get($bin))) { - if ($persist) { - self::persist($bin, self::locateBinary($bin)); - } else { - self::set($bin, self::locateBinary($bin)); - } + self::persist($bin, self::locateBinary($bin)); } } diff --git a/LibreNMS/DB/Eloquent.php b/LibreNMS/DB/Eloquent.php index 6710205b12..1b550eb40f 100644 --- a/LibreNMS/DB/Eloquent.php +++ b/LibreNMS/DB/Eloquent.php @@ -25,59 +25,19 @@ namespace LibreNMS\DB; -use Dotenv\Dotenv; -use Illuminate\Database\Capsule\Manager as Capsule; -use Illuminate\Database\Events\StatementPrepared; -use Illuminate\Events\Dispatcher; -use Illuminate\Support\Arr; +use DB; +use Illuminate\Database\Connection; use LibreNMS\Util\Laravel; +use PDOException; class Eloquent { - /** @var Capsule static reference to capsule */ - private static $capsule; - - public static function boot() - { - // boot Eloquent outside of Laravel - if (! Laravel::isBooted() && is_null(self::$capsule)) { - $install_dir = realpath(__DIR__ . '/../../'); - - Dotenv::createMutable($install_dir)->load(); - - $db_config = include $install_dir . '/config/database.php'; - $settings = $db_config['connections'][$db_config['default']]; - - self::$capsule = new Capsule; - self::$capsule->addConnection($settings); - self::$capsule->setEventDispatcher(new Dispatcher()); - self::$capsule->setAsGlobal(); - self::$capsule->bootEloquent(); - } - - self::initLegacyListeners(); - self::setStrictMode(false); // set non-strict mode if for legacy code - } - - public static function initLegacyListeners() - { - if (self::isConnected()) { - // set FETCH_ASSOC for queries that required by setting the global variable $PDO_FETCH_ASSOC (for dbFacile) - self::DB()->getEventDispatcher()->listen(StatementPrepared::class, function ($event) { - global $PDO_FETCH_ASSOC; - if ($PDO_FETCH_ASSOC) { - $event->statement->setFetchMode(\PDO::FETCH_ASSOC); - } - }); - } - } - /** * Set the strict mode for the current connection (will not persist) * * @param bool $strict */ - public static function setStrictMode($strict = true) + public static function setStrictMode(bool $strict = true): void { if (self::isConnected() && self::getDriver() == 'mysql') { if ($strict) { @@ -88,14 +48,16 @@ class Eloquent } } - public static function isConnected($name = null) + public static function isConnected(?string $name = null): bool { try { $conn = self::DB($name); if ($conn) { - return ! is_null($conn->getPdo()); + $conn->getPdo(); + + return true; } - } catch (\PDOException $e) { + } catch (PDOException $e) { return false; } @@ -105,31 +67,39 @@ class Eloquent /** * Access the Database Manager for Fluent style queries. Like the Laravel DB facade. * - * @param string $name + * @param string|null $name * @return \Illuminate\Database\Connection|null */ - public static function DB($name = null) + public static function DB(?string $name = null): ?Connection { // check if Laravel is booted if (Laravel::isBooted()) { - return \DB::connection($name); + return DB::connection($name); } - if (is_null(self::$capsule)) { - return null; - } - - return self::$capsule->getDatabaseManager()->connection($name); + return null; } - public static function getDriver() + public static function getDriver(): ?string { $connection = config('database.default'); return config("database.connections.{$connection}.driver"); } - public static function setConnection($name, $db_host = null, $db_user = '', $db_pass = '', $db_name = '', $db_port = null, $db_socket = null) + /** + * Set the active connection, used during install + * + * @param string $name + * @param string $db_host + * @param string $db_user + * @param string $db_pass + * @param string $db_name + * @param int|string $db_port + * @param string $db_socket + * @return void + */ + public static function setConnection($name, $db_host = null, $db_user = '', $db_pass = '', $db_name = '', $db_port = null, $db_socket = null): void { \Config::set("database.connections.$name", [ 'driver' => 'mysql', @@ -147,9 +117,4 @@ class Eloquent ]); \Config::set('database.default', $name); } - - public static function version($name = null) - { - return Arr::first(self::DB($name)->selectOne('select version()')); - } } diff --git a/LibreNMS/IRCBot.php b/LibreNMS/IRCBot.php index c06bbb0b14..a5a248138b 100644 --- a/LibreNMS/IRCBot.php +++ b/LibreNMS/IRCBot.php @@ -602,7 +602,7 @@ class IRCBot { if (! Eloquent::isConnected()) { try { - Eloquent::boot(); + Eloquent::DB()->statement('SELECT VERSION()'); } catch (\PDOException $e) { $this->log('Cannot connect to MySQL: ' . $e->getMessage()); diff --git a/LibreNMS/Poller.php b/LibreNMS/Poller.php index b936da22d1..a57ee8ab14 100644 --- a/LibreNMS/Poller.php +++ b/LibreNMS/Poller.php @@ -43,6 +43,7 @@ use LibreNMS\Util\Debug; use LibreNMS\Util\Dns; use LibreNMS\Util\Git; use LibreNMS\Util\StringHelpers; +use LibreNMS\Util\Version; use Psr\Log\LoggerInterface; use Throwable; @@ -371,7 +372,7 @@ EOH, Git::localDate(), vsprintf('%s (%s)', $version->database()), phpversion(), - \LibreNMS\DB\Eloquent::isConnected() ? \LibreNMS\DB\Eloquent::version() : '?', + Version::get()->databaseServer(), $version->rrdtool(), $version->netSnmp() )); diff --git a/LibreNMS/Util/Debug.php b/LibreNMS/Util/Debug.php index 673b1df942..b3b795c070 100644 --- a/LibreNMS/Util/Debug.php +++ b/LibreNMS/Util/Debug.php @@ -26,20 +26,16 @@ namespace LibreNMS\Util; use App; -use Illuminate\Database\Events\QueryExecuted; -use LibreNMS\DB\Eloquent; use Log; class Debug { - /** - * @var bool - */ + /** @var bool */ private static $debug = false; - /** - * @var bool - */ + /** @var bool */ private static $verbose = false; + /** @var bool */ + private static $sql_debug_enabled = false; /** * Enable/disable debug output @@ -52,8 +48,6 @@ class Debug { self::$debug = (bool) $debug; - restore_error_handler(); // disable Laravel error handler - if (self::$debug) { self::enableErrorReporting(); self::enableCliDebugOutput(); @@ -92,18 +86,15 @@ class Debug public static function disableQueryDebug(): void { - $db = Eloquent::DB(); - - if ($db) { - // remove all query executed event handlers - $db->getEventDispatcher()->flush('Illuminate\Database\Events\QueryExecuted'); - } + self::$sql_debug_enabled = false; } public static function enableCliDebugOutput(): void { if (Laravel::isBooted() && App::runningInConsole()) { Log::setDefaultDriver('console_debug'); + } else { + putenv('LOG_CHANNEL=console_debug'); } } @@ -116,28 +107,12 @@ class Debug public static function enableQueryDebug(): void { - static $sql_debug_enabled; - $db = Eloquent::DB(); + self::$sql_debug_enabled = true; + } - if ($db && ! $sql_debug_enabled) { - $db->listen(function (QueryExecuted $query) { - // collect bindings and make them a little more readable - $bindings = collect($query->bindings)->map(function ($item) { - if ($item instanceof \Carbon\Carbon) { - return $item->toDateTimeString(); - } - - return $item; - })->toJson(); - - if (Laravel::isBooted()) { - Log::debug("SQL[%Y{$query->sql} %y$bindings%n {$query->time}ms] \n", ['color' => true]); - } else { - c_echo("SQL[%Y{$query->sql} %y$bindings%n {$query->time}ms] \n"); - } - }); - $sql_debug_enabled = true; - } + public static function queryDebugIsEnabled(): bool + { + return self::$sql_debug_enabled; } /** diff --git a/LibreNMS/Util/Version.php b/LibreNMS/Util/Version.php index 85721d8e1c..fa5ac5133d 100644 --- a/LibreNMS/Util/Version.php +++ b/LibreNMS/Util/Version.php @@ -25,7 +25,9 @@ namespace LibreNMS\Util; +use DB; use Illuminate\Http\Client\ConnectionException; +use Illuminate\Support\Arr; use LibreNMS\Config; use LibreNMS\DB\Eloquent; use Symfony\Component\Process\Process; @@ -100,7 +102,7 @@ class Version public function databaseServer(): string { - return \LibreNMS\DB\Eloquent::isConnected() ? \LibreNMS\DB\Eloquent::version() : 'Not Connected'; + return Eloquent::isConnected() ? Arr::first(DB::selectOne('select version()')) : 'Not Connected'; } public function database(): array diff --git a/LibreNMS/Validations/Database.php b/LibreNMS/Validations/Database.php index e649cf3f66..d311b465cb 100644 --- a/LibreNMS/Validations/Database.php +++ b/LibreNMS/Validations/Database.php @@ -100,7 +100,7 @@ class Database extends BaseValidation private function checkVersion(Validator $validator) { - $version = Eloquent::version(); + $version = \LibreNMS\Util\Version::get()->databaseServer(); $version = explode('-', $version); if (isset($version[1]) && $version[1] == 'MariaDB') { diff --git a/app/Http/Controllers/AboutController.php b/app/Http/Controllers/AboutController.php index 8535252ea7..88a99bc44c 100644 --- a/app/Http/Controllers/AboutController.php +++ b/app/Http/Controllers/AboutController.php @@ -53,7 +53,6 @@ use App\Models\WirelessSensor; use Illuminate\Http\Request; use LibreNMS\Config; use LibreNMS\Data\Store\Rrd; -use LibreNMS\DB\Eloquent; use LibreNMS\Util\Version; class AboutController extends Controller @@ -73,7 +72,7 @@ class AboutController extends Controller 'project_name' => Config::get('project_name'), 'version_local' => $version->local(), - 'version_mysql' => Eloquent::version(), + 'version_mysql' => $version->databaseServer(), 'version_php' => phpversion(), 'version_laravel' => App::VERSION(), 'version_python' => $version->python(), diff --git a/app/Http/Controllers/Auth/SocialiteController.php b/app/Http/Controllers/Auth/SocialiteController.php index b6175ac9d1..a78ba796f5 100644 --- a/app/Http/Controllers/Auth/SocialiteController.php +++ b/app/Http/Controllers/Auth/SocialiteController.php @@ -28,12 +28,10 @@ use Config; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Event; use Laravel\Socialite\Contracts\User as SocialiteUser; use Laravel\Socialite\Facades\Socialite; use LibreNMS\Config as LibreNMSConfig; use LibreNMS\Exceptions\AuthenticationException; -use Log; class SocialiteController extends Controller { @@ -45,23 +43,6 @@ class SocialiteController extends Controller $this->injectConfig(); } - public static function registerEventListeners(): void - { - foreach (LibreNMSConfig::get('auth.socialite.configs', []) as $provider => $config) { - // Treat not set as "disabled" - if (! isset($config['listener'])) { - continue; - } - $listener = $config['listener']; - - if (class_exists($listener)) { - Event::listen(\SocialiteProviders\Manager\SocialiteWasCalled::class, "$listener@handle"); - } else { - Log::error("Wrong value for auth.socialite.configs.$provider.listener set, class: '$listener' does not exist!"); - } - } - } - /** * @return RedirectResponse|\Symfony\Component\HttpFoundation\Response */ diff --git a/app/Listeners/LegacyQueryListener.php b/app/Listeners/LegacyQueryListener.php new file mode 100644 index 0000000000..365952a609 --- /dev/null +++ b/app/Listeners/LegacyQueryListener.php @@ -0,0 +1,33 @@ +statement->setFetchMode(\PDO::FETCH_ASSOC); + } + } +} diff --git a/app/Listeners/QueryDebugListener.php b/app/Listeners/QueryDebugListener.php new file mode 100644 index 0000000000..ad5b0802c8 --- /dev/null +++ b/app/Listeners/QueryDebugListener.php @@ -0,0 +1,43 @@ +bindings)->map(function ($item) { + if ($item instanceof \Carbon\Carbon) { + return $item->toDateTimeString(); + } + + return $item; + })->toJson(); + + Log::debug("SQL[%Y{$query->sql} %y$bindings%n {$query->time}ms] \n", ['color' => true]); + } + } +} diff --git a/app/Listeners/QueryMetricListener.php b/app/Listeners/QueryMetricListener.php new file mode 100644 index 0000000000..75cb889451 --- /dev/null +++ b/app/Listeners/QueryMetricListener.php @@ -0,0 +1,32 @@ +sql, 0, strpos($event->sql, ' '))); + app(MeasurementManager::class)->recordDb(Measurement::make($type, $event->time ? $event->time / 100 : 0)); + } +} diff --git a/app/Polling/Measure/MeasurementManager.php b/app/Polling/Measure/MeasurementManager.php index 5ed79a7a3c..a94f4a8e59 100644 --- a/app/Polling/Measure/MeasurementManager.php +++ b/app/Polling/Measure/MeasurementManager.php @@ -25,8 +25,6 @@ namespace App\Polling\Measure; -use DB; -use Illuminate\Database\Events\QueryExecuted; use Illuminate\Support\Collection; use Log; @@ -51,17 +49,6 @@ class MeasurementManager } } - /** - * Register DB listener to record sql query stats - */ - public function listenDb(): void - { - DB::listen(function (QueryExecuted $event) { - $type = strtolower(substr($event->sql, 0, strpos($event->sql, ' '))); - $this->recordDb(Measurement::make($type, $event->time ? $event->time / 100 : 0)); - }); - } - /** * Update statistics for the given category */ diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 943aed4987..b9dd94658b 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,7 +3,6 @@ namespace App\Providers; use App\Models\Sensor; -use App\Polling\Measure\MeasurementManager; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Log; @@ -46,15 +45,10 @@ class AppServiceProvider extends ServiceProvider * * @return void */ - public function boot(MeasurementManager $measure) + public function boot() { - $measure->listenDb(); \Illuminate\Pagination\Paginator::useBootstrap(); - $this->app->booted('\LibreNMS\DB\Eloquent::initLegacyListeners'); - $this->app->booted('\LibreNMS\Config::load'); - $this->app->booted('\App\Http\Controllers\Auth\SocialiteController::registerEventListeners'); - $this->bootCustomBladeDirectives(); $this->bootCustomValidators(); $this->configureMorphAliases(); diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php new file mode 100644 index 0000000000..2b2560639f --- /dev/null +++ b/app/Providers/ConfigServiceProvider.php @@ -0,0 +1,29 @@ + [ + \App\Listeners\QueryDebugListener::class, + \App\Listeners\QueryMetricListener::class, + ], + \Illuminate\Database\Events\StatementPrepared::class => [ + \App\Listeners\LegacyQueryListener::class, + ], ]; /** diff --git a/app/Providers/SocialiteListenersServiceProvider.php b/app/Providers/SocialiteListenersServiceProvider.php new file mode 100644 index 0000000000..0582284826 --- /dev/null +++ b/app/Providers/SocialiteListenersServiceProvider.php @@ -0,0 +1,41 @@ + $config) { + // Treat not set as "disabled" + if (! isset($config['listener'])) { + continue; + } + $listener = $config['listener']; + + if (class_exists($listener)) { + $this->app['events']->listen(\SocialiteProviders\Manager\SocialiteWasCalled::class, "$listener@handle"); + } else { + $this->app['log']->error("Wrong value for auth.socialite.configs.$provider.listener set, class: '$listener' does not exist!"); + } + } + } +} diff --git a/config/app.php b/config/app.php index b64cdb26a5..d66a19b3f6 100644 --- a/config/app.php +++ b/config/app.php @@ -176,7 +176,7 @@ return [ \SocialiteProviders\Manager\ServiceProvider::class, /* - * Application Service Providers... + * LibreNMS Service Providers... */ App\Providers\AppServiceProvider::class, App\Providers\CliServiceProvider::class, @@ -184,12 +184,12 @@ return [ // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, + + App\Providers\ConfigServiceProvider::class, + App\Providers\SocialiteListenersServiceProvider::class, + App\Providers\ComposerServiceProvider::class, App\Providers\DatastoreServiceProvider::class, - - /* - * LibreNMS Service Providers... - */ App\Providers\SnmptrapProvider::class, App\Providers\PluginProvider::class, ], diff --git a/daily.php b/daily.php index 42eb840375..98532e5e9d 100644 --- a/daily.php +++ b/daily.php @@ -386,8 +386,6 @@ if ($options['f'] === 'recalculate_device_dependencies') { $lock = Cache::lock('recalculate_device_dependencies', 86000); if ($lock->get()) { - \LibreNMS\DB\Eloquent::boot(); - // update all root nodes and recurse, chunk so we don't blow up Device::doesntHave('parents')->with('children')->chunk(100, function (Collection $devices) { // anonymous recursive function diff --git a/includes/dbFacile.php b/includes/dbFacile.php index 241b94a036..95057c844a 100644 --- a/includes/dbFacile.php +++ b/includes/dbFacile.php @@ -22,73 +22,8 @@ use Illuminate\Database\QueryException; use LibreNMS\DB\Eloquent; -use LibreNMS\Exceptions\DatabaseConnectException; use LibreNMS\Util\Laravel; -/** - * @deprecated Please use Eloquent instead; https://laravel.com/docs/eloquent - * @see https://laravel.com/docs/eloquent - */ -function dbIsConnected() -{ - return Eloquent::isConnected(); -} - -/** - * Connect to the database. - * Will use global config variables if they are not sent: db_host, db_user, db_pass, db_name, db_port, db_socket - * - * @param string $db_host - * @param string $db_user - * @param string $db_pass - * @param string $db_name - * @param string $db_port - * @param string $db_socket - * @return \Illuminate\Database\Connection - * - * @throws DatabaseConnectException - * - * @deprecated Please use Eloquent instead; https://laravel.com/docs/eloquent - * @see https://laravel.com/docs/eloquent - */ -function dbConnect($db_host = null, $db_user = '', $db_pass = '', $db_name = '', $db_port = null, $db_socket = null) -{ - if (Eloquent::isConnected()) { - return Eloquent::DB(); - } - - if (! extension_loaded('pdo_mysql')) { - throw new DatabaseConnectException('PHP pdo_mysql extension not loaded!'); - } - - try { - if (! is_null($db_host) || ! empty($db_name)) { - // legacy connection override - \Config::set('database.connections.setup', [ - 'driver' => 'mysql', - 'host' => $db_host, - 'port' => $db_port, - 'database' => $db_name, - 'username' => $db_user, - 'password' => $db_pass, - 'unix_socket' => $db_socket, - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - 'strict' => true, - 'engine' => null, - ]); - \Config::set('database.default', 'setup'); - } - - Eloquent::boot(); - } catch (PDOException $e) { - throw new DatabaseConnectException($e->getMessage(), $e->getCode(), $e); - } - - return Eloquent::DB(); -} - /** * Performs a query using the given string. * diff --git a/includes/init.php b/includes/init.php index 663fafd7d2..cc28879413 100644 --- a/includes/init.php +++ b/includes/init.php @@ -30,6 +30,7 @@ use LibreNMS\Authentication\LegacyAuth; use LibreNMS\Config; use LibreNMS\Util\Debug; +use LibreNMS\Util\Laravel; global $vars, $console_color; @@ -77,22 +78,18 @@ if (module_selected('polling', $init_modules)) { require_once $install_dir . '/includes/polling/functions.inc.php'; } -if (module_selected('alerts', $init_modules)) { - require_once $install_dir . '/LibreNMS/Alert/RunAlerts.php'; -} +Debug::set($debug ?? false); // disable debug initially // Boot Laravel if (module_selected('web', $init_modules)) { - \LibreNMS\Util\Laravel::bootWeb(module_selected('auth', $init_modules)); + Laravel::bootWeb(module_selected('auth', $init_modules)); } else { - \LibreNMS\Util\Laravel::bootCli(); + Laravel::bootCli(); } - -Debug::set(false); // disable debug initially (hides legacy errors too) +Debug::set($debug ?? false); // override laravel configured settings (hides legacy errors too) +restore_error_handler(); // disable Laravel error handler if (! module_selected('nodb', $init_modules)) { - \LibreNMS\DB\Eloquent::boot(); - if (! \LibreNMS\DB\Eloquent::isConnected()) { echo "Could not connect to database, check logs/librenms.log.\n"; @@ -104,18 +101,7 @@ if (! module_selected('nodb', $init_modules)) { exit; } } - -// Display config.php errors instead of http 500 -$display_bak = ini_get('display_errors'); -ini_set('display_errors', 1); - -// Load config if not already loaded (which is the case if inside Laravel) -if (! Config::has('install_dir')) { - Config::load(); -} - -// set display_errors back -ini_set('display_errors', $display_bak); +\LibreNMS\DB\Eloquent::setStrictMode(false); // disable strict mode for legacy code... if (is_numeric(Config::get('php_memory_limit')) && Config::get('php_memory_limit') > 128) { ini_set('memory_limit', Config::get('php_memory_limit') . 'M'); @@ -129,15 +115,9 @@ try { exit(); } -if (module_selected('discovery', $init_modules) && ! \LibreNMS\Util\OS::updateCache(false)) { - // OS::loadAllDefinitions() is called by update_os_cache() if updated, no need to call twice - \LibreNMS\Util\OS::loadAllDefinitions(false, true); -} elseif (module_selected('web', $init_modules)) { +if (module_selected('web', $init_modules)) { + require $install_dir . '/includes/html/vars.inc.php'; \LibreNMS\Util\OS::loadAllDefinitions(! module_selected('nodb', $init_modules), true); } -if (module_selected('web', $init_modules)) { - require $install_dir . '/includes/html/vars.inc.php'; -} - $console_color = new Console_Color2(); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3dbbf1cc19..96b9adf4a0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1740,101 +1740,6 @@ parameters: count: 1 path: LibreNMS/Config.php - - - message: "#^Call to function is_null\\(\\) with Illuminate\\\\Database\\\\Capsule\\\\Manager will always evaluate to false\\.$#" - count: 2 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Call to function is_null\\(\\) with PDO will always evaluate to false\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:boot\\(\\) has no return type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:getDriver\\(\\) has no return type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:initLegacyListeners\\(\\) has no return type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:isConnected\\(\\) has no return type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:isConnected\\(\\) has parameter \\$name with no type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:setConnection\\(\\) has no return type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:setConnection\\(\\) has parameter \\$db_host with no type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:setConnection\\(\\) has parameter \\$db_name with no type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:setConnection\\(\\) has parameter \\$db_pass with no type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:setConnection\\(\\) has parameter \\$db_port with no type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:setConnection\\(\\) has parameter \\$db_socket with no type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:setConnection\\(\\) has parameter \\$db_user with no type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:setConnection\\(\\) has parameter \\$name with no type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:setStrictMode\\(\\) has no return type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:version\\(\\) has no return type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Method LibreNMS\\\\DB\\\\Eloquent\\:\\:version\\(\\) has parameter \\$name with no type specified\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - - - message: "#^Result of && is always false\\.$#" - count: 1 - path: LibreNMS/DB/Eloquent.php - - message: "#^Method LibreNMS\\\\DB\\\\Schema\\:\\:columnExists\\(\\) has no return type specified\\.$#" count: 1 diff --git a/tests/OSDiscoveryTest.php b/tests/OSDiscoveryTest.php index cc3ddb4659..0e13cc4cd5 100644 --- a/tests/OSDiscoveryTest.php +++ b/tests/OSDiscoveryTest.php @@ -126,6 +126,8 @@ class OSDiscoveryTest extends TestCase $os = Core::detectOS($this->genDevice($community)); $output = ob_get_contents(); ob_end_clean(); + Debug::set(false); + Debug::setVerbose(false); $this->assertLessThan(5, microtime(true) - $start, "OS $expected_os took longer than 5s to detect"); $this->assertEquals($expected_os, $os, "Test file: $community.snmprec\n$output");