From 6b4ae1b73fef2457d0f66f6e3d61d98d59227329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20M=C3=BCller?= <2566282+brotkrueml@users.noreply.github.com> Date: Tue, 4 Jan 2022 18:39:00 +0100 Subject: [PATCH] [BUGFIX] Avoid warning when accessing array offset on int On PHP 8 I got this error: PHP Warning: Trying to access array offset on value of type int in /var/www/html/public/typo3conf/ext/page_speed_insights/Classes/FormEngine/Elements/History.php line 60 The patch fixes this. I haven't got an array in my tests, but an int with `0` and a string with `"0"`, so used the `is_numeric()` check. --- Classes/FormEngine/Elements/History.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/FormEngine/Elements/History.php b/Classes/FormEngine/Elements/History.php index 08a3946..0b0c922 100644 --- a/Classes/FormEngine/Elements/History.php +++ b/Classes/FormEngine/Elements/History.php @@ -56,10 +56,10 @@ public function render() } $languageId = 0; - if (array_key_exists('0', (array)$this->data['databaseRow']['sys_language_uid']) && - $this->data['databaseRow']['sys_language_uid'][0] - ) { + if (is_array($this->data['databaseRow']['sys_language_uid']) && ($this->data['databaseRow']['sys_language_uid'][0] ?? false)) { $languageId = (int)$this->data['databaseRow']['sys_language_uid'][0]; + } elseif (is_numeric($this->data['databaseRow']['sys_language_uid'])) { + $languageId = (int)$this->data['databaseRow']['sys_language_uid']; } $resultArray = $this->initializeResultArray();