From ad2d38e894ec0d5db8823031952860c89609e081 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 10 Jul 2023 15:31:41 +0200 Subject: [PATCH 1/5] Provide `Migration` hook --- library/Reporting/Model/Schedule.php | 3 - library/Reporting/Model/Schema.php | 39 +++++++++ .../Reporting/ProvidedHook/DbMigration.php | 83 +++++++++++++++++++ run.php | 2 + schema/mysql-upgrades/1.0.0.sql | 17 ++++ schema/mysql.schema.sql | 16 +++- schema/pgsql-upgrades/1.0.0.sql | 19 +++++ schema/pgsql.schema.sql | 20 ++++- 8 files changed, 190 insertions(+), 9 deletions(-) create mode 100644 library/Reporting/Model/Schema.php create mode 100644 library/Reporting/ProvidedHook/DbMigration.php create mode 100644 schema/mysql-upgrades/1.0.0.sql create mode 100644 schema/pgsql-upgrades/1.0.0.sql diff --git a/library/Reporting/Model/Schedule.php b/library/Reporting/Model/Schedule.php index 7f73aad8..6100d2a4 100644 --- a/library/Reporting/Model/Schedule.php +++ b/library/Reporting/Model/Schedule.php @@ -26,8 +26,6 @@ public function getColumns() return [ 'report_id', 'author', - 'start', - 'frequency', 'action', 'config', 'ctime', @@ -38,7 +36,6 @@ public function getColumns() public function createBehaviors(Behaviors $behaviors) { $behaviors->add(new MillisecondTimestamp([ - 'start', 'ctime', 'mtime' ])); diff --git a/library/Reporting/Model/Schema.php b/library/Reporting/Model/Schema.php new file mode 100644 index 00000000..8abe7b4e --- /dev/null +++ b/library/Reporting/Model/Schema.php @@ -0,0 +1,39 @@ +add(new BoolCast(['success'])); + $behaviors->add(new MillisecondTimestamp(['timestamp'])); + } +} diff --git a/library/Reporting/ProvidedHook/DbMigration.php b/library/Reporting/ProvidedHook/DbMigration.php new file mode 100644 index 00000000..a9019b72 --- /dev/null +++ b/library/Reporting/ProvidedHook/DbMigration.php @@ -0,0 +1,83 @@ +translate('Icinga Reporting'); + } + + public function providedDescriptions(): array + { + return [ + '0.9.1' => $this->translate( + 'Modifies all columns that uses current_timestamp to unix_timestamp and alters the database' + . ' engine of some tables.' + ), + '0.10.0' => $this->translate('Creates the template table and adjusts some column types'), + '1.0.0' => $this->translate('Migrates all your configured report schedules to the new config.') + ]; + } + + protected function getSchemaQuery(): Query + { + return Schema::on($this->getDb()); + } + + public function getDb(): Connection + { + return $this->getReportingDb(); + } + + public function getVersion(): string + { + if ($this->version === null) { + $conn = $this->getDb(); + $schema = $this->getSchemaQuery() + ->columns(['version', 'success']) + ->orderBy('id', SORT_DESC) + ->limit(2); + + if (static::tableExists($conn, $schema->getModel()->getTableName())) { + /** @var Schema $version */ + foreach ($schema as $version) { + if ($version->success) { + $this->version = $version->version; + } + } + + if (! $this->version) { + // Schema version table exist, but the user has probably deleted the entry! + $this->version = '1.0.0'; + } + } elseif (static::tableExists($conn, 'template')) { + // We have added Postgres support and the template table with 0.10.0. + // So, use this as the last (migrated) version. + $this->version = '0.10.0'; + } elseif (static::getColumnType($conn, 'timeframe', 'name') === 'varchar(128)') { + // Upgrade script 0.9.1 alters the timeframe.name column from `varchar(255)` -> `varchar(128)`. + // Therefore, we can safely use this as the last migrated version. + $this->version = '0.9.1'; + } else { + // Use the initial version as the last migrated schema version! + $this->version = '0.9.0'; + } + } + + return $this->version; + } +} diff --git a/run.php b/run.php index ab6c4778..dc7b2922 100644 --- a/run.php +++ b/run.php @@ -8,6 +8,8 @@ /** @var \Icinga\Application\Modules\Module $this */ + $this->provideHook('DbMigration', '\\Icinga\\Module\\Reporting\\ProvidedHook\\DbMigration'); + $this->provideHook('reporting/Report', '\\Icinga\\Module\\Reporting\\Reports\\SystemReport'); $this->provideHook('reporting/Action', '\\Icinga\\Module\\Reporting\\Actions\\SendMail'); diff --git a/schema/mysql-upgrades/1.0.0.sql b/schema/mysql-upgrades/1.0.0.sql new file mode 100644 index 00000000..bdd3721c --- /dev/null +++ b/schema/mysql-upgrades/1.0.0.sql @@ -0,0 +1,17 @@ +ALTER TABLE schedule + DROP COLUMN start, + DROP COLUMN frequency; + +CREATE TABLE reporting_schema ( + id int unsigned NOT NULL AUTO_INCREMENT, + version varchar(64) NOT NULL, + timestamp bigint unsigned NOT NULL, + success enum ('n', 'y') DEFAULT NULL, + reason text DEFAULT NULL, + + PRIMARY KEY (id), + CONSTRAINT idx_reporting_schema_version UNIQUE (version) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; + +INSERT INTO reporting_schema (version, timestamp, success, reason) + VALUES ('1.0.0', UNIX_TIMESTAMP() * 1000, 'y', NULL); diff --git a/schema/mysql.schema.sql b/schema/mysql.schema.sql index 5f704817..bd231bc2 100644 --- a/schema/mysql.schema.sql +++ b/schema/mysql.schema.sql @@ -74,8 +74,6 @@ CREATE TABLE schedule ( id int(10) unsigned NOT NULL AUTO_INCREMENT, report_id int(10) unsigned NOT NULL, author varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci, - start bigint(20) unsigned NOT NULL, - frequency enum('minutely', 'hourly', 'daily', 'weekly', 'monthly'), action varchar(255) NOT NULL, config text NULL DEFAULT NULL, ctime bigint(20) unsigned NOT NULL, @@ -84,6 +82,20 @@ CREATE TABLE schedule ( CONSTRAINT schedule_report FOREIGN KEY (report_id) REFERENCES report (id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +CREATE TABLE reporting_schema ( + id int unsigned NOT NULL AUTO_INCREMENT, + version varchar(64) NOT NULL, + timestamp bigint unsigned NOT NULL, + success enum ('n', 'y') DEFAULT NULL, + reason text DEFAULT NULL, + + PRIMARY KEY (id), + CONSTRAINT idx_reporting_schema_version UNIQUE (version) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; + +INSERT INTO reporting_schema (version, timestamp, success) + VALUES ('1.0.0', UNIX_TIMESTAMP() * 1000, 'y'); + -- CREATE TABLE share ( -- id int(10) unsigned NOT NULL AUTO_INCREMENT, -- report_id int(10) unsigned NOT NULL, diff --git a/schema/pgsql-upgrades/1.0.0.sql b/schema/pgsql-upgrades/1.0.0.sql new file mode 100644 index 00000000..b0f6cfcf --- /dev/null +++ b/schema/pgsql-upgrades/1.0.0.sql @@ -0,0 +1,19 @@ +ALTER TABLE schedule + DROP COLUMN start, + DROP COLUMN frequency; + +CREATE TYPE boolenum AS ENUM ('n', 'y'); + +CREATE TABLE reporting_schema ( + id serial, + version varchar(64) NOT NULL, + timestamp bigint NOT NULL, + success boolenum DEFAULT NULL, + reason text DEFAULT NULL, + + CONSTRAINT pk_reporting_schema PRIMARY KEY (id), + CONSTRAINT idx_reporting_schema_version UNIQUE (version) +); + +INSERT INTO reporting_schema (version, timestamp, success, reason) + VALUES ('1.0.0', unix_timestamp() * 1000, 'y', NULL); diff --git a/schema/pgsql.schema.sql b/schema/pgsql.schema.sql index 329a65f8..d20289c0 100644 --- a/schema/pgsql.schema.sql +++ b/schema/pgsql.schema.sql @@ -1,9 +1,9 @@ +CREATE TYPE boolenum AS ENUM ('n', 'y'); + CREATE OR REPLACE FUNCTION unix_timestamp(timestamp with time zone DEFAULT NOW()) RETURNS bigint AS 'SELECT EXTRACT(EPOCH FROM $1)::bigint' LANGUAGE SQL; -CREATE TYPE frequency AS ENUM ('minutely', 'hourly', 'daily', 'weekly', 'monthly'); - CREATE TABLE template ( id serial PRIMARY KEY, author varchar(255) NOT NULL, @@ -73,11 +73,23 @@ CREATE TABLE schedule ( id serial PRIMARY KEY, report_id int NOT NULL, author varchar(255) NOT NULL, - start bigint NOT NULL, - frequency frequency, action varchar(255) NOT NULL, config text DEFAULT NULL, ctime bigint NOT NULL DEFAULT unix_timestamp() * 1000, mtime bigint NOT NULL DEFAULT unix_timestamp() * 1000, CONSTRAINT schedule_report FOREIGN KEY (report_id) REFERENCES report (id) ON DELETE CASCADE ON UPDATE CASCADE ); + +CREATE TABLE reporting_schema ( + id serial, + version varchar(64) NOT NULL, + timestamp bigint NOT NULL, + success boolenum DEFAULT NULL, + reason text DEFAULT NULL, + + CONSTRAINT pk_reporting_schema PRIMARY KEY (id), + CONSTRAINT idx_reporting_schema_version UNIQUE (version) +); + +INSERT INTO reporting_schema (version, timestamp, success) + VALUES ('1.0.0', UNIX_TIMESTAMP() * 1000, 'y'); From 9f27944b1708eaa71bf5fe00e1f1595b8c366d30 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Wed, 19 Jul 2023 15:21:40 +0200 Subject: [PATCH 2/5] Add `1.0.0` upgrading docs --- doc/80-Upgrading.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index b3f3c407..a2f80671 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -3,6 +3,25 @@ Upgrading Icinga Reporting is straightforward. Usually the only manual steps involved are schema updates for the database. +## Upgrading to Version 1.0.0 + +Icinga Reporting version 1.0.0 requires a schema update for the database. +If you're already using Icinga Web version `>= 2.12`, then you don't need to perform any of these steps manually. +Icinga Web provides you the ability to perform such migrations in a simple way. You may be familiar with such an +automation if you're an Icinga Director user. For those who are not using the latest version of Icinga Web, please +follow the instructions below. + +You may use the following command to apply the database schema upgrade file: + + +**Note:** If you haven't installed this module from packages, then please adapt the schema path to the correct installation path. + + + +``` +# mysql -u root -p reporting /usr/share/icingaweb2/modules/reporting/schema/mysql-upgrades/1.0.0.sql +``` + ## Upgrading to Version 0.10.0 Icinga Reporting version 0.10.0 requires a schema update for the database. From 3931c8200f8b4e66d57bd1c980dc865915418b07 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 8 Aug 2023 13:07:09 +0200 Subject: [PATCH 3/5] Add `migrate_schedule_config()` procedure --- schema/mysql-upgrades/1.0.0.sql | 38 +++++++++++++++++++++++++++++++++ schema/pgsql-upgrades/1.0.0.sql | 25 ++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/schema/mysql-upgrades/1.0.0.sql b/schema/mysql-upgrades/1.0.0.sql index bdd3721c..71a5eb5a 100644 --- a/schema/mysql-upgrades/1.0.0.sql +++ b/schema/mysql-upgrades/1.0.0.sql @@ -1,3 +1,41 @@ +DROP PROCEDURE IF EXISTS migrate_schedule_config; +DELIMITER // +CREATE PROCEDURE migrate_schedule_config() +BEGIN + DECLARE schedule_id int; + DECLARE schedule_start bigint; + DECLARE schedule_frequency enum('minutely', 'hourly', 'daily', 'weekly', 'monthly'); + DECLARE schedule_config text; + + DECLARE frequency_json text; + + DECLARE done int DEFAULT 0; + DECLARE schedule CURSOR FOR SELECT id, start, frequency, config FROM schedule; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; + + OPEN schedule; + read_loop: LOOP + FETCH schedule INTO schedule_id, schedule_start, schedule_frequency, schedule_config; + IF done THEN + LEAVE read_loop; + END IF; + IF NOT INSTR(schedule_config, 'frequencyType') THEN + SET frequency_json = CONCAT( + ',"frequencyType":"\\\\ipl\\\\Scheduler\\\\Cron","frequency":"{', + '\\"expression\\":\\"@', schedule_frequency, + '\\",\\"start\\":\\"', DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(schedule_start / 1000), @@session.TIME_ZONE, 'UTC'), '%Y-%m-%dT%H:%i:%s.%u UTC'), + '\\"}"' + ); + UPDATE schedule SET config = INSERT(schedule_config, LENGTH(schedule_config), 0, frequency_json) WHERE id = schedule_id; + END IF; + END LOOP; + CLOSE schedule; +END // +DELIMITER ; + +CALL migrate_schedule_config(); +DROP PROCEDURE migrate_schedule_config; + ALTER TABLE schedule DROP COLUMN start, DROP COLUMN frequency; diff --git a/schema/pgsql-upgrades/1.0.0.sql b/schema/pgsql-upgrades/1.0.0.sql index b0f6cfcf..0bf3c35a 100644 --- a/schema/pgsql-upgrades/1.0.0.sql +++ b/schema/pgsql-upgrades/1.0.0.sql @@ -1,3 +1,28 @@ +CREATE OR REPLACE PROCEDURE migrate_schedule_config() + LANGUAGE plpgsql + AS $$ + DECLARE + row record; + frequency_json text; + BEGIN + FOR row IN (SELECT id, start, frequency, config FROM schedule) + LOOP + IF NOT CAST(POSITION('frequencyType' IN row.config) AS bool) THEN + frequency_json = CONCAT( + ',"frequencyType":"\\ipl\\Scheduler\\Cron","frequency":"{', + '\"expression\":\"@', row.frequency, + '\",\"start\":\"', TO_CHAR(TO_TIMESTAMP(row.start / 1000) AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US UTC'), + '\"}"' + ); + UPDATE schedule SET config = OVERLAY(row.config PLACING frequency_json FROM LENGTH(row.config) FOR 0) WHERE id = row.id; + END IF; + END LOOP; + END; + $$; + +CALL migrate_schedule_config(); +DROP PROCEDURE migrate_schedule_config; + ALTER TABLE schedule DROP COLUMN start, DROP COLUMN frequency; From d00989b3187576ba7845f71affa5ed2795cf93e6 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Fri, 15 Sep 2023 15:17:33 +0200 Subject: [PATCH 4/5] Fix missing return type hints for `Database::list{Timeframes,Templates}` --- library/Reporting/Database.php | 59 ++++++++----- phpstan-baseline.neon | 150 --------------------------------- 2 files changed, 40 insertions(+), 169 deletions(-) diff --git a/library/Reporting/Database.php b/library/Reporting/Database.php index 24b28fcb..2e9d551c 100644 --- a/library/Reporting/Database.php +++ b/library/Reporting/Database.php @@ -29,33 +29,54 @@ protected function getDb(): RetryConnection return new RetryConnection($config); } - protected function listTimeframes() + /** + * List all reporting timeframes + * + * @return array + */ + protected function listTimeframes(): array { - $select = (new Sql\Select()) - ->from('timeframe') - ->columns(['id', 'name']); - - $timeframes = []; - /** @var stdClass $row */ - foreach ($this->getDb()->select($select) as $row) { - $timeframes[$row->id] = $row->name; - } - - return $timeframes; + return $this->list( + (new Sql\Select()) + ->from('timeframe') + ->columns(['id', 'name']) + ); } - protected function listTemplates() + /** + * List all reporting templates + * + * @return array + */ + protected function listTemplates(): array { - $select = (new Sql\Select()) - ->from('template') - ->columns(['id', 'name']); + return $this->list( + (new Sql\Select()) + ->from('template') + ->columns(['id', 'name']) + ); + } - $templates = []; + /** + * Helper method for list templates and timeframes + * + * @param Sql\Select $select + * + * @return array + */ + private function list(Sql\Select $select): array + { + $result = []; /** @var stdClass $row */ foreach ($this->getDb()->select($select) as $row) { - $templates[$row->id] = $row->name; + /** @var int $id */ + $id = $row->id; + /** @var string $name */ + $name = $row->name; + + $result[$id] = $name; } - return $templates; + return $result; } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index fa9a09ba..c971c031 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -135,16 +135,6 @@ parameters: count: 1 path: application/controllers/ReportController.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\ReportController\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/ReportController.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\ReportController\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/ReportController.php - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\ReportController\\:\\:scheduleAction\\(\\) has no return type specified\\.$#" count: 1 @@ -170,16 +160,6 @@ parameters: count: 1 path: application/controllers/ReportsController.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\ReportsController\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/ReportsController.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\ReportsController\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/ReportsController.php - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\ReportsController\\:\\:newAction\\(\\) has no return type specified\\.$#" count: 1 @@ -195,16 +175,6 @@ parameters: count: 1 path: application/controllers/TemplateController.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\TemplateController\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/TemplateController.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\TemplateController\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/TemplateController.php - - message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#" count: 1 @@ -220,16 +190,6 @@ parameters: count: 1 path: application/controllers/TemplatesController.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\TemplatesController\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/TemplatesController.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\TemplatesController\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/TemplatesController.php - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\TemplatesController\\:\\:newAction\\(\\) has no return type specified\\.$#" count: 1 @@ -240,16 +200,6 @@ parameters: count: 1 path: application/controllers/TimeframeController.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\TimeframeController\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/TimeframeController.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\TimeframeController\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/TimeframeController.php - - message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#" count: 1 @@ -290,16 +240,6 @@ parameters: count: 1 path: application/controllers/TimeframesController.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\TimeframesController\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/TimeframesController.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\TimeframesController\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: application/controllers/TimeframesController.php - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Controllers\\\\TimeframesController\\:\\:newAction\\(\\) has no return type specified\\.$#" count: 1 @@ -355,16 +295,6 @@ parameters: count: 1 path: library/Reporting/Cli/Command.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Cli\\\\Command\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Cli/Command.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Cli\\\\Command\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Cli/Command.php - - message: "#^Property Icinga\\\\Module\\\\Reporting\\\\Cli\\\\Command\\:\\:\\$configs has no type specified\\.$#" count: 1 @@ -580,16 +510,6 @@ parameters: count: 2 path: library/Reporting/Report.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Report\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Report.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Report\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Report.php - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Report\\:\\:providesData\\(\\) has no return type specified\\.$#" count: 1 @@ -890,16 +810,6 @@ parameters: count: 1 path: library/Reporting/Timeframe.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Timeframe\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Timeframe.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Timeframe\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Timeframe.php - - message: "#^Property Icinga\\\\Module\\\\Reporting\\\\Timeframe\\:\\:\\$end \\(string\\) does not accept mixed\\.$#" count: 1 @@ -945,16 +855,6 @@ parameters: count: 1 path: library/Reporting/Web/Forms/ReportForm.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\ReportForm\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Forms/ReportForm.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\ReportForm\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Forms/ReportForm.php - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\ReportForm\\:\\:onSuccess\\(\\) has no return type specified\\.$#" count: 1 @@ -990,16 +890,6 @@ parameters: count: 1 path: library/Reporting/Web/Forms/ScheduleForm.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\ScheduleForm\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Forms/ScheduleForm.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\ScheduleForm\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Forms/ScheduleForm.php - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\ScheduleForm\\:\\:onSuccess\\(\\) has no return type specified\\.$#" count: 1 @@ -1020,16 +910,6 @@ parameters: count: 1 path: library/Reporting/Web/Forms/SendForm.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\SendForm\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Forms/SendForm.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\SendForm\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Forms/SendForm.php - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\SendForm\\:\\:onSuccess\\(\\) has no return type specified\\.$#" count: 1 @@ -1075,16 +955,6 @@ parameters: count: 1 path: library/Reporting/Web/Forms/TemplateForm.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\TemplateForm\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Forms/TemplateForm.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\TemplateForm\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Forms/TemplateForm.php - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\TemplateForm\\:\\:onSuccess\\(\\) has no return type specified\\.$#" count: 1 @@ -1100,16 +970,6 @@ parameters: count: 1 path: library/Reporting/Web/Forms/TimeframeForm.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\TimeframeForm\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Forms/TimeframeForm.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\TimeframeForm\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Forms/TimeframeForm.php - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Forms\\\\TimeframeForm\\:\\:onSuccess\\(\\) has no return type specified\\.$#" count: 1 @@ -1285,16 +1145,6 @@ parameters: count: 1 path: library/Reporting/Web/Widget/Template.php - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Widget\\\\Template\\:\\:listTemplates\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Widget/Template.php - - - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Widget\\\\Template\\:\\:listTimeframes\\(\\) has no return type specified\\.$#" - count: 1 - path: library/Reporting/Web/Widget/Template.php - - message: "#^Method Icinga\\\\Module\\\\Reporting\\\\Web\\\\Widget\\\\Template\\:\\:resolveMacros\\(\\) has no return type specified\\.$#" count: 1 From b9d8ac3c855e9a44f51906063d7bb214dc4beed3 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Tue, 19 Sep 2023 15:21:23 +0200 Subject: [PATCH 5/5] Schema: Add class property type hints --- library/Reporting/Model/Schema.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/Reporting/Model/Schema.php b/library/Reporting/Model/Schema.php index 8abe7b4e..102a6ebe 100644 --- a/library/Reporting/Model/Schema.php +++ b/library/Reporting/Model/Schema.php @@ -4,11 +4,21 @@ namespace Icinga\Module\Reporting\Model; +use DateTime; use ipl\Orm\Behavior\BoolCast; use ipl\Orm\Behavior\MillisecondTimestamp; use ipl\Orm\Behaviors; use ipl\Orm\Model; +/** + * A database model for reporting schema version table + * + * @property int $id Unique identifier of the database schema entries + * @property string $version The current schema version of Icinga Web + * @property DateTime $timestamp The insert/modify time of the schema entry + * @property bool $success Whether the database migration of the current version was successful + * @property ?string $reason The reason why the database migration has failed + */ class Schema extends Model { public function getTableName(): string