Issue Bug Closed

#78276Workspace preview "StageService.php" missing prev/next stage buttons

Michael Schütz 10/13/16, 10:38 updated 08/11/26, 08:46

Description

Hello everybody! I’am new to forge and hope I placed my first issue currectly. If not, give me a hint! Thank you!

The following I found. If I change content in workspace of a table which is not “tt_content”, “pages”, “pages_language_overlay” the stage buttons don’t show up in the preview. I found the reason for that in the files PreviewController.php, ActionHandler.php. In this files there is called the methods “getPreviousStageForElementCollection” and “getNextStageForElementCollection” of file StageService.php but only with the first parameter array “$workspaceItems”. The methods offer a second parameter array “$byTableName” to hand over the table-name where the “$workspaceItems” relate to. The second parameter array is prefilled with the tables “tt_content”, “pages”, “pages_language_overlay”. But if I have a “tt_news” record for example, the stage could not be determined and the buttons stay hidden.

Currently the methods are called like that without the second parameter:
$this->stageService->getNextStageForElementCollection($workspaceItemsArray);
$this->stageService->getPreviousStageForElementCollection($workspaceItemsArray);

I changed it for testing in this way and it works:
if (!empty($workspaceItemsArray)) {
list(, $nextStage) = $this->stageService->getNextStageForElementCollection($workspaceItemsArray, [key($workspaceItemsArray)]);
list(, $previousStage) = $this->stageService->getPreviousStageForElementCollection($workspaceItemsArray, [key($workspaceItemsArray)]);
} else {
list(, $nextStage) = $this->stageService->getNextStageForElementCollection($workspaceItemsArray);
list(, $previousStage) = $this->stageService->getPreviousStageForElementCollection($workspaceItemsArray);
}

If the array “$workspaceItemsArray” is filled, the root-keys are the table-names. So with “[key($workspaceItemsArray)]” I could hand over the table-name and the stage-buttons appear. If you use the discard-button, the array “$workspaceItemsArray” styes empty. For that reason I put the calls into an if/else and call it once with the second parameter and in the otherway without.

I tested it and can’t get any problems so far. Could somebody more experienced with the workspace please check my solution. And would it be possible to correct the behaviour in next TYPO3-Update?

Maybe a better solution could be to prefill the second-parameter array “$byTableName” globaly with all table-names which offer the use of workspace.

foreach ($tables as $key => $table) {
if ($table offers workspace usage) {
$this->byTableName[] = $table->getTableName();
}
}

Good times!

Reviews 2

Files 1

History 712

  1. Michael Schütz changed subject Workspace preview "StageService.php" prev or next stage Workspace preview "StageService.php" missing prev or next stage buttons <span data-processor="relativetime" data-value="2016-10-13T10:39:26+00:00" > 10/13/16, 10:39 </span>

  2. Michael Schütz changed attached stage-buttons.png subject Workspace preview "StageService.php" missing prev or next stage buttons Workspace preview "StageService.php" missing prev/next stage buttons <span data-processor="relativetime" data-value="2016-10-13T10:42:38+00:00" > 10/13/16, 10:42 </span>

  3. Benni Mack commented <span data-processor="relativetime" data-value="2023-11-01T22:02:01+00:00" > 11/01/23, 22:02 </span>

    I guess the main issue here is that we preview a page with e.g. a news record but the news record is on a different page / storage page.

  4. Benni Mack commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-06-24T12:05:27+00:00" > 06/24/26, 12:05 </span>

    Applied in changeset commit:c505bc45df6795daf1bd9556f122fbec251bc94d.