Project

General

Profile

Actions

Bug #93095

open

Persistence Session->hasIdentifier() triggers PHP warning "Illegal offset type in isset or empty" when no instances of class has yet been loaded

Added by Claus Due almost 4 years ago. Updated almost 4 years ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2020-12-17
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.4
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

When calling Session->hasIdentifier() with an identifier that does not exist (because no object of that class type has been fetched), the function will internally call:

return isset($this->identifierMap[$this->getClassIdentifier($className)][$identifier]);

However, $this->identifierMap[$this->getClassIdentifier($className)] will be NULL which means that PHP will attempt to check if `null[$identifier]` is set, which then triggers the warning.

Suggested fix:

$classIdentifier = $this->getClassIdentifier($className);
return isset($this->identifierMap[$classIdentifier], $this->identifierMap[$classIdentifier][$identifier]);

By passing two arguments to isset() the function will return false immediately if the first reference is not set, which in the described use case, it isn't. This then prevents the second reference - which would cause the warning to be triggered - from being evaluated.

Actions

Also available in: Atom PDF