Skip to content

Commit

Permalink
[BUGFIX] Fix array access warnings in EditDocumentController
Browse files Browse the repository at this point in the history
$this->firstEl is checked for !== null several times in
EditDocumentController, but it most certainly isn't, because
reset() returns false instead of null, if the array is empty.

This patch resolves this problem by setting $this->firstEl to
null, if reset($this->elementsData) returned false.

Resolves: #96342
Releases: main, 11.5
Change-Id: I45b7aff02d7b601e16fd05862542a9e3955de908
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72638
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: physikbuddha <r.kaerner@oranto.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: physikbuddha <r.kaerner@oranto.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
  • Loading branch information
Physikbuddha authored and bmack committed Dec 13, 2021
1 parent e34e3d9 commit 5281b26
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -1023,7 +1023,7 @@ protected function main(ServerRequestInterface $request): void
// Creating the editing form, wrap it with buttons, document selector etc.
$editForm = $this->makeEditForm();
if ($editForm) {
$this->firstEl = reset($this->elementsData);
$this->firstEl = $this->elementsData ? reset($this->elementsData) : null;
// Checking if the currently open document is stored in the list of "open documents" - if not, add it:
if ((($this->docDat[1] ?? null) !== $this->storeUrlMd5 || !isset($this->docHandler[$this->storeUrlMd5]))
&& !$this->dontStoreDocumentRef
Expand Down

0 comments on commit 5281b26

Please sign in to comment.