Commit 6985d726 authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[BUGFIX] Prevent PHP warnings in workspace ActionHandler

* $parameters->additional might not be set,
   depending on the workspace configuration
* There might be no "next" or "prev" stage,
   depending on the current stage

Resolves: #97368
Releases: main, 11.5
Change-Id: Ic1a5452adb33f900bc2c8c0c86ee1d5d9849d290
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74283


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Oliver Klee's avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent e09e2df2
......@@ -424,7 +424,7 @@ class ActionHandler
if (!is_object($parameters->affects) || empty($parameters->affects)) {
throw new \InvalidArgumentException('Missing "affected items" in $parameters array.', 1319488195);
}
$recipients = $this->getRecipientList((array)($parameters->recipients ?? []), $parameters->additional, $stageId);
$recipients = $this->getRecipientList((array)($parameters->recipients ?? []), (string)($parameters->additional ?? ''), $stageId);
foreach ($parameters->affects as $tableName => $items) {
foreach ($items as $item) {
// Publishing uses live id in command map
......@@ -500,7 +500,7 @@ class ActionHandler
$uid = $parameters->affects->uid;
$t3ver_oid = $parameters->affects->t3ver_oid;
$recipients = $this->getRecipientList((array)($parameters->recipients ?? []), $parameters->additional, $setStageId);
$recipients = $this->getRecipientList((array)($parameters->recipients ?? []), (string)($parameters->additional ?? ''), $setStageId);
if ($setStageId === StagesService::STAGE_PUBLISH_EXECUTE_ID) {
$cmdArray[$table][$t3ver_oid]['version']['action'] = 'publish';
$cmdArray[$table][$t3ver_oid]['version']['swapWith'] = $uid;
......@@ -542,7 +542,7 @@ class ActionHandler
$table = $parameters->affects->table;
$uid = $parameters->affects->uid;
$recipients = $this->getRecipientList((array)($parameters->recipients ?? []), $parameters->additional, $setStageId);
$recipients = $this->getRecipientList((array)($parameters->recipients ?? []), (string)($parameters->additional ?? ''), $setStageId);
$cmdArray[$table][$uid]['version']['action'] = 'setStage';
$cmdArray[$table][$uid]['version']['stageId'] = $setStageId;
$cmdArray[$table][$uid]['version']['comment'] = $comments;
......@@ -582,7 +582,7 @@ class ActionHandler
$setStageId = (int)$parameters->affects->nextStage;
$comments = $parameters->comments;
$elements = $parameters->affects->elements;
$recipients = $this->getRecipientList((array)($parameters->recipients ?? []), $parameters->additional, $setStageId);
$recipients = $this->getRecipientList((array)($parameters->recipients ?? []), (string)($parameters->additional ?? ''), $setStageId);
foreach ($elements as $element) {
// Avoid any action on records that have already been published to live
$elementRecord = BackendUtility::getRecord($element->table, $element->uid);
......@@ -774,11 +774,11 @@ class ActionHandler
$view->assignMultiple([
'enablePreviousStageButton' => is_array($previousStage) && !empty($previousStage),
'enableNextStageButton' => is_array($nextStage) && !empty($nextStage),
'enableDiscardStageButton' => is_array($nextStage) && !empty($nextStage) || is_array($previousStage) && !empty($previousStage),
'nextStage' => $nextStage['title'],
'nextStageId' => $nextStage['uid'],
'prevStage' => $previousStage['title'],
'prevStageId' => $previousStage['uid'],
'enableDiscardStageButton' => (is_array($nextStage) && !empty($nextStage)) || (is_array($previousStage) && !empty($previousStage)),
'nextStage' => $nextStage['title'] ?? '',
'nextStageId' => $nextStage['uid'] ?? 0,
'prevStage' => $previousStage['title'] ?? '',
'prevStageId' => $previousStage['uid'] ?? 0,
]);
return $view->render('Preview/Ajax/StageButtons');
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment