From ea2b55067e8b777ffcb587611094188734474d7d Mon Sep 17 00:00:00 2001 From: Benni Mack Date: Fri, 17 Dec 2021 17:31:33 +0100 Subject: [PATCH] [BUGFIX] Avoid PHP 8.0 warnings --- Classes/Hooks/DataHandlerHook.php | 2 +- Classes/Hooks/PageLayoutHeaderHook.php | 2 +- Classes/Notification/NotificationManager.php | 4 ++-- Classes/Utility/ArchiveUtility.php | 4 ++-- Configuration/TCA/Overrides/sys_category.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Classes/Hooks/DataHandlerHook.php b/Classes/Hooks/DataHandlerHook.php index 8e121572..26aeebf3 100644 --- a/Classes/Hooks/DataHandlerHook.php +++ b/Classes/Hooks/DataHandlerHook.php @@ -54,7 +54,7 @@ public function processDatamap_afterDatabaseOperations($status, $table, $id, arr ->execute() ->fetch(); if (!empty($record)) { - $timestamp = (int) (!empty($record['publish_date']) ? $record['publish_date'] : time()); + $timestamp = (int) (!empty($record['publish_date'] ?? 0) ? $record['publish_date'] : time()); $queryBuilder ->update($table) ->set('publish_date', $timestamp) diff --git a/Classes/Hooks/PageLayoutHeaderHook.php b/Classes/Hooks/PageLayoutHeaderHook.php index 37fc7903..b85c61f6 100644 --- a/Classes/Hooks/PageLayoutHeaderHook.php +++ b/Classes/Hooks/PageLayoutHeaderHook.php @@ -31,7 +31,7 @@ public function drawHeader() $pageInfo = BackendUtility::readPageAccess($pageUid, $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW)); // Early exit for non-blog pages - if ($pageInfo['doktype'] !== Constants::DOKTYPE_BLOG_POST) { + if (($pageInfo['doktype'] ?? 0) !== Constants::DOKTYPE_BLOG_POST) { return ''; } diff --git a/Classes/Notification/NotificationManager.php b/Classes/Notification/NotificationManager.php index 0d445b58..28169d77 100644 --- a/Classes/Notification/NotificationManager.php +++ b/Classes/Notification/NotificationManager.php @@ -24,7 +24,7 @@ public function __construct() { $notificationRegistry = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['Blog']['notificationRegistry'] ?? []; foreach ($notificationRegistry as $notificationId => $visitorClassNames) { - if (!\is_array($this->visitorsRegistry[$notificationId])) { + if (!\is_array($this->visitorsRegistry[$notificationId] ?? null)) { $this->visitorsRegistry[$notificationId] = []; } foreach ($visitorClassNames as $visitorClassName) { @@ -40,7 +40,7 @@ public function __construct() public function notify(NotificationInterface $notification): void { $notificationId = $notification->getNotificationId(); - if (\is_array($this->visitorsRegistry[$notificationId])) { + if (\is_array($this->visitorsRegistry[$notificationId] ?? null)) { foreach ($this->visitorsRegistry[$notificationId] as $visitorClassName) { $instance = GeneralUtility::makeInstance($visitorClassName); if ($instance instanceof ProcessorInterface) { diff --git a/Classes/Utility/ArchiveUtility.php b/Classes/Utility/ArchiveUtility.php index e9d3d663..a5a06b72 100644 --- a/Classes/Utility/ArchiveUtility.php +++ b/Classes/Utility/ArchiveUtility.php @@ -36,10 +36,10 @@ public static function extractDataFromPosts(array $data): array { $archiveData = []; foreach ($data as $result) { - if (empty($archiveData[$result['year']])) { + if (empty($archiveData[$result['year'] ?? null])) { $archiveData[$result['year']] = []; } - $dateTime = new \DateTimeImmutable(sprintf('%d-%d-1', (int)$result['year'], (int)$result['month'])); + $dateTime = new \DateTimeImmutable(sprintf('%d-%d-1', (int)($result['year'] ?? 0), (int)($result['month'] ?? 0))); $result['timestamp'] = $dateTime->getTimestamp(); $archiveData[$result['year']][] = $result; } diff --git a/Configuration/TCA/Overrides/sys_category.php b/Configuration/TCA/Overrides/sys_category.php index eeaadfe4..b7ff8f97 100644 --- a/Configuration/TCA/Overrides/sys_category.php +++ b/Configuration/TCA/Overrides/sys_category.php @@ -53,7 +53,7 @@ 'foreign_table_where' => '' . ' AND sys_category.record_type = ' . (string) \T3G\AgencyPack\Blog\Constants::CATEGORY_TYPE_BLOG . ' ' . ' AND sys_category.pid = ###CURRENT_PID### ' . - $GLOBALS['TCA']['pages']['columns']['categories']['config']['foreign_table_where'] + ($GLOBALS['TCA']['pages']['columns']['categories']['config']['foreign_table_where'] ?? '') ] ] ];