From 11e470b3038dae76f4ff6955920f1a212880653d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 14 Jan 2022 13:54:27 +0100 Subject: [PATCH 1/6] Avoid passing non-string args to `ctype_*()` functions --- library/Icingadb/Model/Behavior/Bitmask.php | 2 +- library/Icingadb/Model/Behavior/IdKey.php | 2 +- library/Icingadb/Model/Behavior/Timestamp.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/Icingadb/Model/Behavior/Bitmask.php b/library/Icingadb/Model/Behavior/Bitmask.php index 0207589e..f8d91f62 100644 --- a/library/Icingadb/Model/Behavior/Bitmask.php +++ b/library/Icingadb/Model/Behavior/Bitmask.php @@ -62,7 +62,7 @@ class Bitmask extends PropertyBehavior implements RewriteFilterBehavior $values = $condition->getValue(); if (! is_array($values)) { - if (ctype_digit($values)) { + if (is_int($values) || ctype_digit($values)) { return; } diff --git a/library/Icingadb/Model/Behavior/IdKey.php b/library/Icingadb/Model/Behavior/IdKey.php index ddc903df..bdad3c16 100644 --- a/library/Icingadb/Model/Behavior/IdKey.php +++ b/library/Icingadb/Model/Behavior/IdKey.php @@ -19,7 +19,7 @@ class IdKey implements RewriteFilterBehavior $column = $condition->metaData()->get('columnName'); if ($column === 'id' || substr($column, -3) === '_id') { $value = $condition->getValue(); - if ($value && ctype_alnum($value)) { + if ($value && is_string($value) && ctype_alnum($value)) { $condition->setValue(hex2bin($value)); } } diff --git a/library/Icingadb/Model/Behavior/Timestamp.php b/library/Icingadb/Model/Behavior/Timestamp.php index b29b3d62..b3654910 100644 --- a/library/Icingadb/Model/Behavior/Timestamp.php +++ b/library/Icingadb/Model/Behavior/Timestamp.php @@ -23,7 +23,7 @@ class Timestamp extends PropertyBehavior return $value; } - if (! ctype_digit($value)) { + if (is_string($value) && ! ctype_digit($value)) { $timestamp = strtotime($value); if ($timestamp === false) { return $value; From 649803b1cbb1914dab48698c1b3b1e267b04cbf2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 14 Jan 2022 13:55:02 +0100 Subject: [PATCH 2/6] Ensure Return Type Compatibility with Internal Classes --- doc/02-Installation.md | 2 +- library/Icingadb/Redis/VolatileStateResults.php | 4 ++-- library/Icingadb/Setup/IcingaDbWizard.php | 2 +- module.info | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/02-Installation.md b/doc/02-Installation.md index 4dc4b6f8..8ddba64b 100644 --- a/doc/02-Installation.md +++ b/doc/02-Installation.md @@ -12,7 +12,7 @@ * The following PHP modules must be installed: cURL, dom, json, libxml, pdo * [Icinga DB](https://github.com/Icinga/icingadb) * [Icinga Web 2](https://github.com/Icinga/icingaweb2) (>= 2.9) -* [Icinga PHP Library (ipl)](https://github.com/Icinga/icinga-php-library) (>= 0.7) +* [Icinga PHP Library (ipl)](https://github.com/Icinga/icinga-php-library) (>= 0.8) * [Icinga PHP Thirdparty](https://github.com/Icinga/icinga-php-thirdparty) (>= 0.10) * For exports to PDF the [pdfexport](https://github.com/Icinga/icingaweb2-module-pdfexport) (>= 0.10) module is required (Optional) diff --git a/library/Icingadb/Redis/VolatileStateResults.php b/library/Icingadb/Redis/VolatileStateResults.php index d65e8bef..86cceb7a 100644 --- a/library/Icingadb/Redis/VolatileStateResults.php +++ b/library/Icingadb/Redis/VolatileStateResults.php @@ -27,7 +27,7 @@ class VolatileStateResults extends ResultSet return parent::current(); } - public function key() + public function key(): int { if (! $this->updatesApplied && ! $this->isCacheDisabled) { $this->rewind(); @@ -36,7 +36,7 @@ class VolatileStateResults extends ResultSet return parent::key(); } - public function rewind() + public function rewind(): void { if (! $this->updatesApplied && ! $this->isCacheDisabled) { $this->updatesApplied = true; diff --git a/library/Icingadb/Setup/IcingaDbWizard.php b/library/Icingadb/Setup/IcingaDbWizard.php index 5c3b45a0..d3d20823 100644 --- a/library/Icingadb/Setup/IcingaDbWizard.php +++ b/library/Icingadb/Setup/IcingaDbWizard.php @@ -73,7 +73,7 @@ class IcingaDbWizard extends Wizard implements SetupWizard } $set->add(new WebLibraryRequirement([ - 'condition' => ['icinga-php-library', '>=', '0.7.0'], + 'condition' => ['icinga-php-library', '>=', '0.8.0'], 'alias' => 'Icinga PHP library', 'description' => t('The Icinga PHP library (IPL) is required for Icinga DB Web') ])); diff --git a/module.info b/module.info index 379ee174..8be36381 100644 --- a/module.info +++ b/module.info @@ -1,6 +1,6 @@ Module: icingadb Version: 1.0.0-rc2 Requires: - Libraries: icinga-php-library (>=0.7.0), icinga-php-thirdparty (>=0.10.0) + Libraries: icinga-php-library (>=0.8.0), icinga-php-thirdparty (>=0.10.0) Description: Icinga DB Web UI for Icinga DB – Provides a graphical interface to your Icinga monitoring From 964e4485616e60d6cd502dfb3e8c7416cfb43b72 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 14 Jan 2022 13:55:55 +0100 Subject: [PATCH 3/6] Don't perform static calls on traits --- library/Icingadb/Widget/Detail/ObjectDetail.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/Icingadb/Widget/Detail/ObjectDetail.php b/library/Icingadb/Widget/Detail/ObjectDetail.php index 2aeb6475..c2898ed5 100644 --- a/library/Icingadb/Widget/Detail/ObjectDetail.php +++ b/library/Icingadb/Widget/Detail/ObjectDetail.php @@ -17,11 +17,11 @@ use Icinga\Module\Icingadb\Common\HostLinks; use Icinga\Module\Icingadb\Common\Icons; use Icinga\Module\Icingadb\Common\Links; use Icinga\Module\Icingadb\Common\Macros; +use Icinga\Module\Icingadb\Compat\CompatHost; use Icinga\Module\Icingadb\Model\CustomvarFlat; use Icinga\Module\Icingadb\Web\Navigation\Action; use Icinga\Module\Icingadb\Widget\MarkdownText; use Icinga\Module\Icingadb\Common\ServiceLinks; -use Icinga\Module\Icingadb\Compat\CompatObject; use Icinga\Module\Icingadb\Forms\Command\Object\ToggleObjectFeaturesForm; use Icinga\Module\Icingadb\Hook\ActionsHook\ObjectActionsHook; use Icinga\Module\Icingadb\Hook\ExtensionHook\ObjectDetailExtensionHook; @@ -34,7 +34,6 @@ use Icinga\Module\Icingadb\Widget\EmptyState; use Icinga\Module\Icingadb\Widget\StateChange; use ipl\Web\Widget\HorizontalKeyValue; use Icinga\Module\Icingadb\Widget\ItemList\CommentList; -use Icinga\Module\Icingadb\Widget\Detail\PerfDataTable; use Icinga\Module\Icingadb\Widget\PluginOutputContainer; use Icinga\Module\Icingadb\Widget\ShowMore; use Icinga\Module\Icingadb\Widget\TagList; @@ -75,7 +74,7 @@ class ObjectDetail extends BaseHtmlElement public function __construct($object) { $this->object = $object; - $this->compatObject = CompatObject::fromModel($object); + $this->compatObject = CompatHost::fromModel($object); $this->objectType = $object instanceof Host ? 'host' : 'service'; } From 00ad1ef8530880838156e3c13efffdf27a339144 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 14 Jan 2022 14:03:10 +0100 Subject: [PATCH 4/6] Require PHP 7.2+ --- .github/workflows/php.yml | 5 +---- README.md | 2 +- doc/02-Installation.md | 3 +-- library/Icingadb/Setup/IcingaDbWizard.php | 24 ++++------------------- 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index ab725be1..1edcb32f 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -17,11 +17,8 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + php: ['7.2', '7.3', '7.4', '8.0'] os: ['ubuntu-latest'] - include: - - php: '7.0' - allow_failure: true steps: - name: Checkout code base diff --git a/README.md b/README.md index d9f8eefe..45a28a44 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Icinga DB Web -[![PHP Support](https://img.shields.io/badge/php-%3E%3D%207.0-777BB4?logo=PHP)](https://php.net/) +[![PHP Support](https://img.shields.io/badge/php-%3E%3D%207.2-777BB4?logo=PHP)](https://php.net/) ![Build Status](https://github.com/icinga/icingaweb2-module-icingadb/workflows/PHP%20Tests/badge.svg?branch=master) [![Github Tag](https://img.shields.io/github/tag/Icinga/icingaweb2-module-icingadb.svg)](https://github.com/Icinga/icingaweb2-module-icingadb) diff --git a/doc/02-Installation.md b/doc/02-Installation.md index 8ddba64b..72692a09 100644 --- a/doc/02-Installation.md +++ b/doc/02-Installation.md @@ -6,8 +6,7 @@ ## Requirements -* PHP (>= 7.3) - * Older versions (7.0+) still work, but may stop doing so with near future updates +* PHP (>= 7.2) * MySQL or PostgreSQL PHP libraries * The following PHP modules must be installed: cURL, dom, json, libxml, pdo * [Icinga DB](https://github.com/Icinga/icingadb) diff --git a/library/Icingadb/Setup/IcingaDbWizard.php b/library/Icingadb/Setup/IcingaDbWizard.php index d3d20823..5b6812dd 100644 --- a/library/Icingadb/Setup/IcingaDbWizard.php +++ b/library/Icingadb/Setup/IcingaDbWizard.php @@ -51,26 +51,10 @@ class IcingaDbWizard extends Wizard implements SetupWizard { $set = new RequirementSet(); - $phpVersion = Platform::getPhpVersion(); - - if ( - version_compare($phpVersion, '7.0', '>=') - && version_compare($phpVersion, '7.3', '<') - ) { - $set->add(new PhpVersionRequirement([ - 'optional' => true, - 'condition' => ['>=', '7.3'], - 'description' => t( - 'For Icinga DB Web PHP 7.3+ is highly recommended.' - . ' Older versions still work, but may stop doing so with near future updates.' - ) - ])); - } else { - $set->add(new PhpVersionRequirement([ - 'condition' => ['>=', '7.3'], - 'description' => t('Icinga DB Web requires PHP version 7.3.') - ])); - } + $set->add(new PhpVersionRequirement([ + 'condition' => ['>=', '7.2'], + 'description' => sprintf(t('Icinga DB Web requires PHP version %s.'), '7.2') + ])); $set->add(new WebLibraryRequirement([ 'condition' => ['icinga-php-library', '>=', '0.8.0'], From 664947da5f25191b2ce0b900d48cf1c3712241b8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 14 Jan 2022 14:03:38 +0100 Subject: [PATCH 5/6] Run tests on PHP 8.1 --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 1edcb32f..716b5802 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.2', '7.3', '7.4', '8.0'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1'] os: ['ubuntu-latest'] steps: From 7e2bbc4d8afeb86839eb2a0ea7c7825c113b4a72 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 24 Mar 2022 15:51:25 +0100 Subject: [PATCH 6/6] Update.. REQUIREMENTS (yay) --- doc/02-Installation.md | 4 ++-- library/Icingadb/Setup/IcingaDbWizard.php | 5 ++--- module.info | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/02-Installation.md b/doc/02-Installation.md index 72692a09..9d29db45 100644 --- a/doc/02-Installation.md +++ b/doc/02-Installation.md @@ -11,8 +11,8 @@ * The following PHP modules must be installed: cURL, dom, json, libxml, pdo * [Icinga DB](https://github.com/Icinga/icingadb) * [Icinga Web 2](https://github.com/Icinga/icingaweb2) (>= 2.9) -* [Icinga PHP Library (ipl)](https://github.com/Icinga/icinga-php-library) (>= 0.8) -* [Icinga PHP Thirdparty](https://github.com/Icinga/icinga-php-thirdparty) (>= 0.10) +* [Icinga PHP Library (ipl)](https://github.com/Icinga/icinga-php-library) (>= 0.9) +* [Icinga PHP Thirdparty](https://github.com/Icinga/icinga-php-thirdparty) (>= 0.11) * For exports to PDF the [pdfexport](https://github.com/Icinga/icingaweb2-module-pdfexport) (>= 0.10) module is required (Optional) diff --git a/library/Icingadb/Setup/IcingaDbWizard.php b/library/Icingadb/Setup/IcingaDbWizard.php index 5b6812dd..2ad514a5 100644 --- a/library/Icingadb/Setup/IcingaDbWizard.php +++ b/library/Icingadb/Setup/IcingaDbWizard.php @@ -4,7 +4,6 @@ namespace Icinga\Module\Icingadb\Setup; -use Icinga\Application\Platform; use Icinga\Module\Setup\Forms\SummaryPage; use Icinga\Module\Setup\Requirement\PhpModuleRequirement; use Icinga\Module\Setup\Requirement\PhpVersionRequirement; @@ -57,13 +56,13 @@ class IcingaDbWizard extends Wizard implements SetupWizard ])); $set->add(new WebLibraryRequirement([ - 'condition' => ['icinga-php-library', '>=', '0.8.0'], + 'condition' => ['icinga-php-library', '>=', '0.9.0'], 'alias' => 'Icinga PHP library', 'description' => t('The Icinga PHP library (IPL) is required for Icinga DB Web') ])); $set->add(new WebLibraryRequirement([ - 'condition' => ['icinga-php-thirdparty', '>=', '0.10.0'], + 'condition' => ['icinga-php-thirdparty', '>=', '0.11.0'], 'alias' => 'Icinga PHP Thirdparty', 'description' => t('The Icinga PHP Thirdparty library is required for Icinga DB Web') ])); diff --git a/module.info b/module.info index 8be36381..c4e497f7 100644 --- a/module.info +++ b/module.info @@ -1,6 +1,6 @@ Module: icingadb Version: 1.0.0-rc2 Requires: - Libraries: icinga-php-library (>=0.8.0), icinga-php-thirdparty (>=0.10.0) + Libraries: icinga-php-library (>=0.9.0), icinga-php-thirdparty (>=0.11.0) Description: Icinga DB Web UI for Icinga DB – Provides a graphical interface to your Icinga monitoring