Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/forms/MoveRotationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion application/forms/RotationConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Error404Response extends Response
{
public function __construct(string $endpointName = null)
public function __construct(?string $endpointName = null)
{
parent::__construct(
response: 404,
Expand Down
2 changes: 1 addition & 1 deletion library/Notifications/Api/V1/ContactGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion library/Notifications/Api/V1/Contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 9 additions & 1 deletion library/Notifications/Common/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'";
}

Expand Down
9 changes: 4 additions & 5 deletions library/Notifications/Daemon/Daemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion library/Notifications/Web/Form/ContactForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion library/Notifications/Widget/ShowMore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion library/Notifications/Widget/TimeGrid/BaseGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion library/Notifications/Widget/Timeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading