diff --git a/application/forms/MoveRotationForm.php b/application/forms/MoveRotationForm.php index 1a8825a42..f3555607e 100644 --- a/application/forms/MoveRotationForm.php +++ b/application/forms/MoveRotationForm.php @@ -35,7 +35,7 @@ class MoveRotationForm extends Form * * @param ?Connection $db */ - public function __construct(Connection $db = null) + public function __construct(?Connection $db = null) { $this->db = $db; } diff --git a/application/forms/RotationConfigForm.php b/application/forms/RotationConfigForm.php index 28c83afa9..7d0f3cd00 100644 --- a/application/forms/RotationConfigForm.php +++ b/application/forms/RotationConfigForm.php @@ -584,9 +584,11 @@ public function removeRotation(int $id): void /** * Remove all versions of the rotation from the database * + * @param ?int $priority + * * @return void */ - public function wipeRotation(int $priority = null): void + public function wipeRotation(?int $priority = null): void { $priority = $priority ?? $this->getValue('priority'); if ($priority === null) { diff --git a/library/Notifications/Api/Middleware/MiddlewarePipeline.php b/library/Notifications/Api/Middleware/MiddlewarePipeline.php index 2418b1c2f..9cd806b1f 100644 --- a/library/Notifications/Api/Middleware/MiddlewarePipeline.php +++ b/library/Notifications/Api/Middleware/MiddlewarePipeline.php @@ -82,7 +82,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface * * @return ResponseInterface */ - public function execute(ServerRequestInterface $request = null): ResponseInterface + public function execute(?ServerRequestInterface $request = null): ResponseInterface { if ($request === null) { $request = new ServerRequest('GET', '/'); // initial dummy request diff --git a/library/Notifications/Api/OpenApiDescriptionElement/Response/Error404Response.php b/library/Notifications/Api/OpenApiDescriptionElement/Response/Error404Response.php index 4c1b7bac6..0b51ed313 100644 --- a/library/Notifications/Api/OpenApiDescriptionElement/Response/Error404Response.php +++ b/library/Notifications/Api/OpenApiDescriptionElement/Response/Error404Response.php @@ -13,7 +13,7 @@ class Error404Response extends Response { - public function __construct(string $endpointName = null) + public function __construct(?string $endpointName = null) { parent::__construct( response: 404, diff --git a/library/Notifications/Api/V1/ContactGroups.php b/library/Notifications/Api/V1/ContactGroups.php index 666d98048..ab62da058 100644 --- a/library/Notifications/Api/V1/ContactGroups.php +++ b/library/Notifications/Api/V1/ContactGroups.php @@ -763,7 +763,7 @@ public function prepareRow(stdClass $row): void * * @throws HttpException if the username already exists */ - private function assertUniqueName(string $name, int $contactgroupId = null): void + private function assertUniqueName(string $name, ?int $contactgroupId = null): void { $stmt = (new Select()) ->from('contactgroup') diff --git a/library/Notifications/Api/V1/Contacts.php b/library/Notifications/Api/V1/Contacts.php index f7bdab2bf..1165d727c 100644 --- a/library/Notifications/Api/V1/Contacts.php +++ b/library/Notifications/Api/V1/Contacts.php @@ -860,7 +860,7 @@ private function removeContact(int $id): void * * @throws HttpException if the username already exists */ - private function assertUniqueUsername(string $username, int $contactId = null): void + private function assertUniqueUsername(string $username, ?int $contactId = null): void { $stmt = (new Select()) ->from('contact') diff --git a/library/Notifications/Common/Database.php b/library/Notifications/Common/Database.php index c5fc689e2..27202f590 100644 --- a/library/Notifications/Common/Database.php +++ b/library/Notifications/Common/Database.php @@ -78,7 +78,15 @@ private static function getConnection(): Connection $config->options = [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ]; if ($config->db === 'mysql') { - $config->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET SESSION SQL_MODE='STRICT_TRANS_TABLES" + // As of PHP 8.5, driver-specific constants of the PDO class are deprecated, + // but the replacement constants are only available since PHP 8.4. + if (version_compare(PHP_VERSION, '8.4.0', '<')) { + $mysqlAttrInitCommand = PDO::MYSQL_ATTR_INIT_COMMAND; + } else { + $mysqlAttrInitCommand = Pdo\Mysql::ATTR_INIT_COMMAND; + } + + $config->options[$mysqlAttrInitCommand] = "SET SESSION SQL_MODE='STRICT_TRANS_TABLES" . ",NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'"; } diff --git a/library/Notifications/Daemon/Daemon.php b/library/Notifications/Daemon/Daemon.php index 374c23be9..f4fdd319e 100644 --- a/library/Notifications/Daemon/Daemon.php +++ b/library/Notifications/Daemon/Daemon.php @@ -22,8 +22,7 @@ use React\EventLoop\Loop; use React\EventLoop\LoopInterface; -use function Clue\React\Block\await; -use function React\Promise\Timer\sleep; +use function React\Async\delay; class Daemon extends EventEmitter { @@ -264,7 +263,7 @@ protected function processNotifications(): void /** @var IncidentHistory $notification */ $notificationsToProcess = []; foreach ($notifications as $notification) { - if (isset($connections[$notification->contact_id])) { + if ($notification->contact_id !== null && isset($connections[$notification->contact_id])) { ObjectsRendererHook::register($notification->incident->object); $notificationsToProcess[] = $notification; @@ -323,8 +322,8 @@ protected function run(): void $endMs = (int) (microtime(true) * 1000); if (($endMs - $beginMs) < 3000) { - // run took less than 3 seconds; sleep for the remaining duration to prevent heavy db loads - await(sleep((3000 - ($endMs - $beginMs)) / 1000)); + // run took less than 3 seconds; delay for the remaining duration to prevent heavy db loads + delay((3000 - ($endMs - $beginMs)) / 1000); } } self::$logger::debug(self::PREFIX . "cancellation triggered; exiting loop"); diff --git a/library/Notifications/Web/Form/ContactForm.php b/library/Notifications/Web/Form/ContactForm.php index 693f10a56..f41bffe5a 100644 --- a/library/Notifications/Web/Form/ContactForm.php +++ b/library/Notifications/Web/Form/ContactForm.php @@ -176,7 +176,7 @@ protected function assemble() $contact->registerElement($defaultChannel); - $this->addAddressElements($availableTypes, $channelTypes[$defaultChannel->getValue()] ?? null); + $this->addAddressElements($availableTypes, $channelTypes[$defaultChannel->getValue() ?? ''] ?? null); $this->addHtml(new HtmlElement('hr')); diff --git a/library/Notifications/Widget/Detail/IncidentQuickActions.php b/library/Notifications/Widget/Detail/IncidentQuickActions.php index 4bdb95cc5..54d88c8e8 100644 --- a/library/Notifications/Widget/Detail/IncidentQuickActions.php +++ b/library/Notifications/Widget/Detail/IncidentQuickActions.php @@ -221,7 +221,7 @@ protected function unsubscribe(IncidentContact $incidentContact): void * * @return void */ - protected function updateHistory(IncidentContact $incidentContact, string $newRole = null): void + protected function updateHistory(IncidentContact $incidentContact, ?string $newRole = null): void { $oldRole = $incidentContact->role; $contactId = $incidentContact->contact_id ?? $this->currentUserId; diff --git a/library/Notifications/Widget/ShowMore.php b/library/Notifications/Widget/ShowMore.php index 652cae36a..51d38c1bb 100644 --- a/library/Notifications/Widget/ShowMore.php +++ b/library/Notifications/Widget/ShowMore.php @@ -24,7 +24,7 @@ class ShowMore extends BaseHtmlElement protected $label; - public function __construct(ResultSet $resultSet, Url $url, string $label = null) + public function __construct(ResultSet $resultSet, Url $url, ?string $label = null) { $this->label = $label; $this->resultSet = $resultSet; diff --git a/library/Notifications/Widget/TimeGrid/BaseGrid.php b/library/Notifications/Widget/TimeGrid/BaseGrid.php index 7fc94f4cc..ddec9d675 100644 --- a/library/Notifications/Widget/TimeGrid/BaseGrid.php +++ b/library/Notifications/Widget/TimeGrid/BaseGrid.php @@ -253,7 +253,7 @@ final protected function yieldFlowingEntries(Traversable $entries): Generator $cellOccupiers[$rowStart][$column][] = spl_object_id($entry); } - $occupiedCells->attach($entry, $rows); + $occupiedCells->offsetSet($entry, $rows); } $rowPlacements = []; diff --git a/library/Notifications/Widget/Timeline.php b/library/Notifications/Widget/Timeline.php index 18e4afa8a..0120ca648 100644 --- a/library/Notifications/Widget/Timeline.php +++ b/library/Notifications/Widget/Timeline.php @@ -222,7 +222,7 @@ public function getEntries(): Traversable foreach ($occupiedCells as $cell => $entry) { $cells = $entryToCellsMap[$entry] ?? []; $cells[] = $cell; - $entryToCellsMap->attach($entry, $cells); + $entryToCellsMap->offsetSet($entry, $cells); } foreach ($entryToCellsMap as $entry) {