Skip to content

Commit c539c0d

Browse files
committed
[BUGFIX] generate editor preview URLs without workspace split compare
Avoid passing the active workspace into preview URI generation for the visual editor. This stops the editor from rendering the workspace split compare preview and keeps page editing in the regular frontend view.
1 parent 31b35e3 commit c539c0d

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

.gitattributes

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Exclude development and local-only files from git archive / TER zip exports.
2+
3+
.codex export-ignore
4+
.editorconfig export-ignore
5+
.gitignore export-ignore
6+
.github/ export-ignore
7+
.idea/ export-ignore
8+
9+
grumphp.yml export-ignore
10+
phpstan-baseline-13.neon export-ignore
11+
phpstan-baseline-14.neon export-ignore
12+
phpstan-baseline.neon export-ignore
13+
phpstan.neon export-ignore
14+
rector.php export-ignore
15+
16+
public/ export-ignore
17+
var/ export-ignore
18+
vendor/ export-ignore
19+
20+
Resources/Public/JavaScript/tsconfig.json export-ignore
21+
Resources/Public/JavaScript/**/*.test.js export-ignore

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/vendor/
44
/composer.lock
55
/public/
6-
phpstan-baseline.neon
6+
/phpstan-baseline.neon
7+
/.codex

Classes/Backend/Controller/PageEditController.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
2525
use TYPO3\CMS\Backend\Utility\BackendUtility;
2626
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
27+
use TYPO3\CMS\Core\Context\Context;
2728
use TYPO3\CMS\Core\Database\Connection;
2829
use TYPO3\CMS\Core\Database\ConnectionPool;
2930
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
@@ -95,6 +96,7 @@ public function __construct(
9596
private readonly Typo3Version $typo3Version,
9697
private readonly ConnectionPool $connectionPool,
9798
private readonly AssetCollector $assetCollector,
99+
private readonly Context $context,
98100
) {
99101
}
100102

@@ -204,7 +206,20 @@ private function iframeUrl(ServerRequestInterface $request, SiteLanguage $siteLa
204206
];
205207
$previewUriBuilder = PreviewUriBuilder::create($this->pageRecord->getRawRecord()->toArray())
206208
->withAdditionalQueryParameters($parameters);
207-
$uri = $previewUriBuilder->buildUri();
209+
210+
// unset the context workspace so we do not get the split screen workspace preview in the editor.
211+
$context = clone $this->context;
212+
$context->unsetAspect('workspace');
213+
214+
// setting the workspace in $GLOBALS['BE_USER'] is needed until https://review.typo3.org/c/Packages/TYPO3.CMS/+/93603 is merged and than the lowest supported version includes it.
215+
$workspace = $this->getBackendUser()->workspace;
216+
$this->getBackendUser()->workspace = 0;
217+
try {
218+
$uri = $previewUriBuilder->buildUri(context: $context);
219+
} finally {
220+
$this->getBackendUser()->workspace = $workspace;
221+
}
222+
208223
if (!$uri instanceof UriInterface) {
209224
throw new InvalidArgumentException('Could not generate preview URI for page ' . $this->pageRecord->getUid(), 4148517490);
210225
}

0 commit comments

Comments
 (0)