Commit 9c4aecd2 authored by Christian Kuhn's avatar Christian Kuhn Committed by Andreas Fernandez
Browse files

[BUGFIX] Drop "All workspaces" tab from workspace module

When "All workspaces" has been integrated somewhere before v6,
it was advertised as a view to see changes from all workspaces.
This however never worked: When calling the workspace module,
"All workspaces" is empty. If switching to a workspace and then
selecting "All workspaces", the tab shows only the changes of
the selected workspace - identical to the normal workspace tab.
Tracing this back in time, this behavior exists at least since v7.
There is not a single bug report in forge about this.

Since this tab is broken for such a long time without any
report, we assume the functionality is barely needed.

A better solution would be to show the number of existing
changes next to the workspace name in the tab list, so editors
can quickly see which specific workspace needs attention, and
then switch to the workspace in question. This should be done with
another patch since non-admins currently see only one workspace tab
at a time, which needs another preparation patch to fix.

This patch drops the broken "All workspaces" tab for now, preparing
further bugfixes to finally end up with a working solution.

Resolves: #91999
Releases: master, 10.4
Change-Id: I33f3cdba117b68927eb10447b0541d8975ed0a63
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65322


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 4bf6ac54
......@@ -278,11 +278,6 @@ class Backend extends Workspaces {
+ '&returnUrl=' + encodeURIComponent(document.location.href)
+ '&id=' + TYPO3.settings.Workspaces.id + '&edit[' + row.dataset.table + '][' + row.dataset.uid + ']=edit';
// Append workspace of record in all-workspaces view
if (TYPO3.settings.Workspaces.allView) {
newUrl += '&workspace=' + row.dataset.t3ver_wsid;
}
window.location.href = newUrl;
}).on('click', '[data-action="version"]', (e: JQueryEventObject): void => {
const row = <HTMLTableRowElement>e.currentTarget.closest('tr');
......
......@@ -213,13 +213,6 @@ class EditDocumentController
*/
protected $returnEditConf;
/**
* Workspace used for the editing action.
*
* @var string|null
*/
protected $workspace;
/**
* parse_url() of current requested URI, contains ['path'] and ['query'] parts.
*
......@@ -457,7 +450,6 @@ class EditDocumentController
$this->closeDoc = (int)($parsedBody['closeDoc'] ?? $queryParams['closeDoc'] ?? self::DOCUMENT_CLOSE_MODE_DEFAULT);
$this->doSave = (bool)($parsedBody['doSave'] ?? $queryParams['doSave'] ?? false);
$this->returnEditConf = (bool)($parsedBody['returnEditConf'] ?? $queryParams['returnEditConf'] ?? false);
$this->workspace = $parsedBody['workspace'] ?? $queryParams['workspace'] ?? null;
$this->uc = $parsedBody['uc'] ?? $queryParams['uc'] ?? null;
// Set overrideVals as default values if defVals does not exist.
......@@ -491,11 +483,6 @@ class EditDocumentController
}
}
// Sets a temporary workspace, this request is based on
if ($this->workspace !== null) {
$this->getBackendUser()->setTemporaryWorkspace($this->workspace);
}
$event = new BeforeFormEnginePageInitializedEvent($this, $request);
$this->eventDispatcher->dispatch($event);
return null;
......@@ -2374,7 +2361,7 @@ class EditDocumentController
{
// @todo: Refactor in TYPO3 v10: This GeneralUtility method fiddles with _GP()
$this->storeArray = GeneralUtility::compileSelectedGetVarsFromArray(
'edit,defVals,overrideVals,columnsOnly,noView,workspace',
'edit,defVals,overrideVals,columnsOnly,noView',
$this->R_URL_getvars
);
$this->storeUrl = HttpUtility::buildQueryString($this->storeArray, '&');
......
......@@ -18,7 +18,6 @@ namespace TYPO3\CMS\Workspaces\Controller\Remote;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Exception;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -86,9 +85,6 @@ class ActionHandler
*/
public function swapSingleRecord($table, $t3ver_oid, $orig_uid)
{
$versionRecord = BackendUtility::getRecord($table, $orig_uid);
$currentWorkspace = $this->setTemporaryWorkspace($versionRecord['t3ver_wsid']);
$cmd = [];
$cmd[$table][$t3ver_oid]['version'] = [
'action' => 'swap',
......@@ -96,8 +92,6 @@ class ActionHandler
'swapIntoWS' => 1
];
$this->processTcaCmd($cmd);
$this->setTemporaryWorkspace($currentWorkspace);
}
/**
......@@ -109,16 +103,11 @@ class ActionHandler
*/
public function deleteSingleRecord($table, $uid)
{
$versionRecord = BackendUtility::getRecord($table, $uid);
$currentWorkspace = $this->setTemporaryWorkspace($versionRecord['t3ver_wsid']);
$cmd = [];
$cmd[$table][$uid]['version'] = [
'action' => 'clearWSID'
];
$this->processTcaCmd($cmd);
$this->setTemporaryWorkspace($currentWorkspace);
}
/**
......@@ -249,8 +238,6 @@ class ActionHandler
public function sendToNextStageWindow($uid, $table, $t3ver_oid)
{
$elementRecord = BackendUtility::getRecord($table, $uid);
$currentWorkspace = $this->setTemporaryWorkspace($elementRecord['t3ver_wsid']);
if (is_array($elementRecord)) {
$workspaceRecord = WorkspaceRecord::get($elementRecord['t3ver_wsid']);
$nextStageRecord = $workspaceRecord->getNextStage($elementRecord['t3ver_stage']);
......@@ -269,8 +256,6 @@ class ActionHandler
} else {
$result = $this->getErrorResponse('error.sendToNextStage.noRecordFound', 1287264776);
}
$this->setTemporaryWorkspace($currentWorkspace);
return $result;
}
......@@ -284,8 +269,6 @@ class ActionHandler
public function sendToPrevStageWindow($uid, $table)
{
$elementRecord = BackendUtility::getRecord($table, $uid);
$currentWorkspace = $this->setTemporaryWorkspace($elementRecord['t3ver_wsid']);
if (is_array($elementRecord)) {
$workspaceRecord = WorkspaceRecord::get($elementRecord['t3ver_wsid']);
$stageRecord = $workspaceRecord->getStage($elementRecord['t3ver_stage']);
......@@ -310,8 +293,6 @@ class ActionHandler
} else {
$result = $this->getErrorResponse('error.sendToNextStage.noRecordFound', 1287264765);
}
$this->setTemporaryWorkspace($currentWorkspace);
return $result;
}
......@@ -545,9 +526,6 @@ class ActionHandler
$uid = $parameters->affects->uid;
$t3ver_oid = $parameters->affects->t3ver_oid;
$elementRecord = BackendUtility::getRecord($table, $uid);
$currentWorkspace = $this->setTemporaryWorkspace($elementRecord['t3ver_wsid']);
$recipients = $this->getRecipientList((array)$parameters->recipients, $parameters->additional, $setStageId);
if ($setStageId === StagesService::STAGE_PUBLISH_EXECUTE_ID) {
$cmdArray[$table][$t3ver_oid]['version']['action'] = 'swap';
......@@ -565,7 +543,6 @@ class ActionHandler
'success' => true
];
$this->setTemporaryWorkspace($currentWorkspace);
return $result;
}
......@@ -591,9 +568,6 @@ class ActionHandler
$table = $parameters->affects->table;
$uid = $parameters->affects->uid;
$elementRecord = BackendUtility::getRecord($table, $uid);
$currentWorkspace = $this->setTemporaryWorkspace($elementRecord['t3ver_wsid']);
$recipients = $this->getRecipientList((array)$parameters->recipients, $parameters->additional, $setStageId);
$cmdArray[$table][$uid]['version']['action'] = 'setStage';
$cmdArray[$table][$uid]['version']['stageId'] = $setStageId;
......@@ -604,7 +578,6 @@ class ActionHandler
'success' => true
];
$this->setTemporaryWorkspace($currentWorkspace);
return $result;
}
......@@ -843,28 +816,6 @@ class ActionHandler
return $renderedView;
}
/**
* @param int $workspaceId
* @return int Id of the original workspace
* @throws Exception
*/
protected function setTemporaryWorkspace($workspaceId)
{
$workspaceId = (int)$workspaceId;
$currentWorkspace = (int)$this->getBackendUser()->workspace;
if ($currentWorkspace !== $workspaceId) {
if (!$this->getBackendUser()->setTemporaryWorkspace($workspaceId)) {
throw new Exception(
'Cannot set temporary workspace to "' . $workspaceId . '"',
1371484524
);
}
}
return $currentWorkspace;
}
/**
* @return BackendUserAuthentication
*/
......
......@@ -58,8 +58,7 @@ class MassActionHandler
$currentWorkspace = $this->getCurrentWorkspace();
$backendUser = $this->getBackendUser();
$massActionsEnabled = (bool)($backendUser->getTSConfig()['options.']['workspaces.']['enableMassActions'] ?? true);
// in case we're working within "All Workspaces" we can't provide Mass Actions
if ($currentWorkspace != WorkspaceService::SELECT_ALL_WORKSPACES && $massActionsEnabled) {
if ($massActionsEnabled) {
$publishAccess = $backendUser->workspacePublishAccess($currentWorkspace);
if ($publishAccess && !($backendUser->workspaceRec['publish_access'] & 1)) {
$actions[] = ['action' => 'publish', 'title' => $this->getLanguageService()->sL($this->pathToLocallang . ':label_doaction_publish')];
......
......@@ -116,11 +116,7 @@ class RemoteServer
*/
public function getStageActions()
{
$currentWorkspace = $this->getCurrentWorkspace();
$stages = [];
if ($currentWorkspace != WorkspaceService::SELECT_ALL_WORKSPACES) {
$stages = $this->stagesService->getStagesForWSUser();
}
$stages = $this->stagesService->getStagesForWSUser();
$data = [
'total' => count($stages),
'data' => $stages
......
......@@ -171,8 +171,6 @@ class ReviewController extends ActionController
$backendUser->setWorkspace($activeWorkspace);
$performWorkspaceSwitch = true;
BackendUtility::setUpdateSignal('updatePageTree');
} elseif ($switchWs == WorkspaceService::SELECT_ALL_WORKSPACES) {
$this->redirect('fullIndex');
}
}
}
......@@ -201,36 +199,6 @@ class ReviewController extends ActionController
->setIcon($iconFactory->getIcon('actions-version-workspaces-preview-link', Icon::SIZE_SMALL));
$buttonBar->addButton($showButton);
}
$backendUser->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace);
}
/**
* Renders the review module user dependent.
* The module will show all records of all workspaces.
*/
public function fullIndexAction()
{
$wsService = GeneralUtility::makeInstance(WorkspaceService::class);
$wsList = $wsService->getAvailableWorkspaces();
$activeWorkspace = $this->getBackendUser()->workspace;
if (!$this->getBackendUser()->isAdmin()) {
$wsCur = [$activeWorkspace => true];
$wsList = array_intersect_key($wsList, $wsCur);
}
$this->pageRenderer->addInlineSetting('Workspaces', 'workspaceTabs', $this->prepareWorkspaceTabs($wsList, WorkspaceService::SELECT_ALL_WORKSPACES));
$this->pageRenderer->addInlineSetting('Workspaces', 'activeWorkspaceId', WorkspaceService::SELECT_ALL_WORKSPACES);
$this->view->assignMultiple([
'pageUid' => (int)GeneralUtility::_GP('id'),
'showGrid' => true,
'showLegend' => true,
'workspaceList' => $this->prepareWorkspaceTabs($wsList, $activeWorkspace),
'activeWorkspaceUid' => WorkspaceService::SELECT_ALL_WORKSPACES
]);
$this->getBackendUser()->setAndSaveSessionData('tx_workspace_activeWorkspace', WorkspaceService::SELECT_ALL_WORKSPACES);
// set flag for javascript
$this->pageRenderer->addInlineSetting('Workspaces', 'allView', '1');
}
/**
......@@ -247,7 +215,7 @@ class ReviewController extends ActionController
$this->view->assignMultiple([
'pageUid' => (int)GeneralUtility::_GP('id'),
'showGrid' => true,
'workspaceList' => $this->prepareWorkspaceTabs($wsList, (int)$activeWorkspace, false),
'workspaceList' => $this->prepareWorkspaceTabs($wsList, (int)$activeWorkspace),
'activeWorkspaceUid' => $activeWorkspace,
]);
$this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
......@@ -258,16 +226,13 @@ class ReviewController extends ActionController
*
* @param array $workspaceList
* @param int $activeWorkspace
* @param bool $showAllWorkspaceTab
* @return array
*/
protected function prepareWorkspaceTabs(array $workspaceList, int $activeWorkspace, bool $showAllWorkspaceTab = true)
protected function prepareWorkspaceTabs(array $workspaceList, int $activeWorkspace)
{
$tabs = [];
if ($activeWorkspace !== WorkspaceService::SELECT_ALL_WORKSPACES
&& $activeWorkspace !== WorkspaceService::LIVE_WORKSPACE_ID
) {
if ($activeWorkspace !== WorkspaceService::LIVE_WORKSPACE_ID) {
$tabs[] = [
'title' => $workspaceList[$activeWorkspace],
'itemId' => 'workspace-' . $activeWorkspace,
......@@ -276,15 +241,6 @@ class ReviewController extends ActionController
];
}
if ($showAllWorkspaceTab) {
$tabs[] = [
'title' => 'All workspaces',
'itemId' => 'workspace-' . WorkspaceService::SELECT_ALL_WORKSPACES,
'workspaceId' => WorkspaceService::SELECT_ALL_WORKSPACES,
'triggerUrl' => $this->getModuleUri(WorkspaceService::SELECT_ALL_WORKSPACES),
];
}
foreach ($workspaceList as $workspaceId => $workspaceTitle) {
if ($workspaceId === $activeWorkspace
|| $workspaceId === WorkspaceService::LIVE_WORKSPACE_ID
......@@ -314,12 +270,6 @@ class ReviewController extends ActionController
'id' => $this->pageId,
'workspace' => $workspaceId,
];
// The "all workspaces" tab is handled in fullIndexAction
// which is required as additional GET parameter in the URI then
if ($workspaceId === WorkspaceService::SELECT_ALL_WORKSPACES) {
$this->uriBuilder->reset()->uriFor('fullIndex');
$parameters = array_merge($parameters, $this->uriBuilder->getArguments());
}
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute('web_WorkspacesWorkspaces', $parameters);
}
......
......@@ -1118,7 +1118,6 @@ class DataHandlerHook
{
$workspacesCache = GeneralUtility::makeInstance(CacheManager::class)->getCache('workspaces_cache');
$workspacesCache->flushByTag($workspaceId);
$workspacesCache->flushByTag(WorkspaceService::SELECT_ALL_WORKSPACES);
}
/*******************************
......
......@@ -45,7 +45,6 @@ class WorkspaceService implements SingletonInterface
protected $pagesWithVersionsInTable = [];
const TABLE_WORKSPACE = 'sys_workspace';
const SELECT_ALL_WORKSPACES = -98;
const LIVE_WORKSPACE_ID = 0;
/**
......@@ -87,18 +86,7 @@ class WorkspaceService implements SingletonInterface
*/
public function getCurrentWorkspace()
{
$workspaceId = $GLOBALS['BE_USER']->workspace;
$activeId = $GLOBALS['BE_USER']->getSessionData('tx_workspace_activeWorkspace');
// Avoid invalid workspace settings
if ($activeId !== null && $activeId !== self::SELECT_ALL_WORKSPACES) {
$availableWorkspaces = $this->getAvailableWorkspaces();
if (isset($availableWorkspaces[$activeId])) {
$workspaceId = $activeId;
}
}
return $workspaceId;
return $GLOBALS['BE_USER']->workspace;
}
/**
......@@ -376,19 +364,11 @@ class WorkspaceService implements SingletonInterface
);
}
// For "real" workspace numbers, select by that.
// If = -98, select all that are NOT online (zero).
// Anything else below -1 will not select on the wsid and therefore select all!
if ($wsid > self::SELECT_ALL_WORKSPACES) {
if ($wsid >= 0) {
$constraints[] = $queryBuilder->expr()->eq(
'A.t3ver_wsid',
$queryBuilder->createNamedParameter($wsid, \PDO::PARAM_INT)
);
} elseif ($wsid === self::SELECT_ALL_WORKSPACES) {
$constraints[] = $queryBuilder->expr()->neq(
'A.t3ver_wsid',
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
);
}
if ((int)$stage !== -99) {
......@@ -469,7 +449,7 @@ class WorkspaceService implements SingletonInterface
$queryBuilder->expr()->eq('B.uid', $queryBuilder->quoteIdentifier('C.t3ver_oid'))
];
if ($wsid > self::SELECT_ALL_WORKSPACES) {
if ($wsid >= 0) {
$constraints[] = $queryBuilder->expr()->eq(
'A.t3ver_wsid',
$queryBuilder->createNamedParameter($wsid, \PDO::PARAM_INT)
......@@ -478,15 +458,6 @@ class WorkspaceService implements SingletonInterface
'C.t3ver_wsid',
$queryBuilder->createNamedParameter($wsid, \PDO::PARAM_INT)
);
} elseif ($wsid === self::SELECT_ALL_WORKSPACES) {
$constraints[] = $queryBuilder->expr()->neq(
'A.t3ver_wsid',
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
);
$constraints[] = $queryBuilder->expr()->neq(
'C.t3ver_wsid',
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
);
}
if ((int)$stage != -99) {
......
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="module" />
<f:section name="main">
<f:render partial="WorkingTable" arguments="{_all}" />
</f:section>
</html>
......@@ -70,23 +70,6 @@ class WorkspaceServiceTest extends FunctionalTestCase
self::assertEquals(1, $result['pages'][0]['livepid'], 'Real pid wasn\'t resolved correctly');
}
/**
* @test
*/
public function versionsFromAllWorkspaceCanBeFound()
{
$this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml');
$this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
$service = new WorkspaceService();
$result = $service->selectVersionsInWorkspace(WorkspaceService::SELECT_ALL_WORKSPACES, -99, 2);
self::assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
self::assertCount(
2,
$result['pages'],
'The result is supposed to contain one version for this page in workspace 91'
);
}
/**
* @test
*/
......
......@@ -10,7 +10,7 @@ defined('TYPO3_MODE') or die();
'before:info',
[
// An array holding the controller-action-combinations that are accessible
\TYPO3\CMS\Workspaces\Controller\ReviewController::class => 'index,fullIndex,singleIndex'
\TYPO3\CMS\Workspaces\Controller\ReviewController::class => 'index,singleIndex'
],
[
'access' => 'user,group',
......
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