Fix PHP Warning (#92)

First check for existence before accessing.
The ObjectStorage itself has no check which will result in an PHP
warning due to accessing a none existing array key.

Relates: #10197
This commit is contained in:
Daniel Siepmann 2023-01-05 14:51:07 +01:00 committed by GitHub
parent 928f42e7fc
commit 45eda76e98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -95,8 +95,11 @@ class ImportConfiguration extends AbstractEntity implements ImportConfigurationI
public function getLastImported(): ?\DateTimeImmutable
{
$positionOfLastLog = count($this->logs) - 1;
$lastImport = $this->logs->offsetGet((string) $positionOfLastLog);
$lastImport = null;
$positionOfLastLog = (string) (count($this->logs) - 1);
if ($this->logs->offsetExists($positionOfLastLog)) {
$lastImport = $this->logs->offsetGet($positionOfLastLog);
}
if (!$lastImport instanceof ImportLog) {
return null;
}