Commit 7768d5e7 authored by Benni Mack's avatar Benni Mack Committed by Jigal van Hemert
Browse files

[TASK] Remove last occurrences of default draft workspace

The default draft workspace was deprecated with TYPO3 4.4,
and removed with TYPO3 4.6, but some parts were still left in TYPO3 Core,
and can simply removed now.

Default draft workspace was always marked as "-1", where as "0" was the
live workspace, and everything greater zero is a regular workspace we use
throughout the TYPO3 Core.

See https://typo3.org/news/article/bringing-workspaces-up-to-speed/
for more information about the deprecation.

Resolves: #84026
Releases: master
Change-Id: Ic85425425c4a091bc058091cd483351d84b4d912
Reviewed-on: https://review.typo3.org/55880


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarMathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: default avatarMathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Jigal van Hemert's avatarJigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert's avatarJigal van Hemert <jigal.van.hemert@typo3.org>
parent efeb346e
......@@ -28,6 +28,7 @@ use TYPO3\CMS\Core\Resource\ResourceStorage;
use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -83,7 +84,6 @@ class BackendUserAuthentication extends AbstractUserAuthentication
/**
* User workspace.
* -99 is ERROR (none available)
* -1 is offline
* 0 is online
* >0 is custom workspaces
* @var int
......@@ -2242,37 +2242,33 @@ class BackendUserAuthentication extends AbstractUserAuthentication
/**
* Return default workspace ID for user,
* If EXT:workspaces is not installed the user will be pushed the the
* Live workspace
* if EXT:workspaces is not installed the user will be pushed to the
* Live workspace, if he has access to. If no workspace is available for the user, the workspace ID is set to "-99"
*
* @return int Default workspace id. If no workspace is available it will be "-99
* @return int Default workspace id.
*/
public function getDefaultWorkspace()
{
if (!ExtensionManagementUtility::isLoaded('workspaces')) {
return 0;
}
// Online is default
if ($this->checkWorkspace(0)) {
return 0;
}
// Otherwise -99 is the fallback
$defaultWorkspace = -99;
if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('workspaces') || $this->checkWorkspace(0)) {
// Check online
$defaultWorkspace = 0;
} elseif ($this->checkWorkspace(-1)) {
// Check offline
$defaultWorkspace = -1;
} elseif (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('workspaces')) {
// Traverse custom workspaces:
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_workspace');
$queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(RootLevelRestriction::class));
$workspaces = $queryBuilder->select('uid', 'title', 'adminusers', 'members', 'reviewers')
->from('sys_workspace')
->orderBy('title')
->execute()
->fetchAll(\PDO::FETCH_ASSOC);
if ($workspaces !== false) {
foreach ($workspaces as $rec) {
if ($this->checkWorkspace($rec)) {
$defaultWorkspace = $rec['uid'];
break;
}
}
// Traverse all workspaces
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_workspace');
$queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(RootLevelRestriction::class));
$result = $queryBuilder->select('*')
->from('sys_workspace')
->orderBy('title')
->execute();
while ($workspaceRecord = $result->fetch()) {
if ($this->checkWorkspace($workspaceRecord)) {
$defaultWorkspace = (int)$workspaceRecord['uid'];
break;
}
}
return $defaultWorkspace;
......
......@@ -914,7 +914,7 @@ You can name bookmarks, you can even group them and share them. If you want to e
<trans-unit id="workspaceSelector.details" xml:space="preserve">
<source>There are two basic workspace types in TYPO3: The "Live" workspace and a number of "Draft" workspaces.
When working in the Live workspace all changes you make will take immediate effect. This is the default and traditional state of operation in TYPO3.
When working in the default Draft workspace or any customly created workspaces changes are not applied to the live website but rather made through new versions of any element editable. Since versioning doesn't apply to all elements in TYPO3 there are limitations to what can be done in draft workspaces; Only elements with versioning support can be edited and everything else is read-only. Draft workspaces allow preview in the frontend. When changes are final in a draft workspace they can be published into the live workspace.</source>
When working in a customly created workspaces changes are not applied to the live website but rather made through new versions of any element editable. Since versioning doesn't apply to all elements in TYPO3 there are limitations to what can be done in draft workspaces; Only elements with versioning support can be edited and everything else is read-only. Draft workspaces allow preview in the frontend. When changes are final in a draft workspace they can be published into the live workspace.</source>
</trans-unit>
</body>
</file>
......
......@@ -1116,12 +1116,8 @@ class TypoScriptFrontendController implements LoggerAwareInterface
(
$backendUser->user['workspace_preview']
|| GeneralUtility::_GP('ADMCMD_view')
|| $this->doWorkspacePreview()
)
&& (
$this->whichWorkspace() === -1
|| $this->whichWorkspace() > 0
)
&& $this->whichWorkspace() > 0
&& !GeneralUtility::_GP('ADMCMD_noBeUser')
) {
// Will show special preview message.
......@@ -1202,8 +1198,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
->execute()
->fetch();
$workspace = $this->whichWorkspace();
if ($workspace !== 0 && $workspace !== false) {
if ($this->whichWorkspace() > 0) {
// Fetch overlay of page if in workspace and check if it is hidden
$pageSelectObject = GeneralUtility::makeInstance(PageRepository::class);
$pageSelectObject->versioningPreview = true;
......@@ -3180,8 +3175,8 @@ class TypoScriptFrontendController implements LoggerAwareInterface
*/
public function setSysLastChanged()
{
// Draft workspaces are always uid 1 or more. We do not update SYS_LASTCHANGED if we are browsing page from one of theses workspaces
if ((int)$this->whichWorkspace() < 1 && $this->page['SYS_LASTCHANGED'] < (int)$this->register['SYS_LASTCHANGED']) {
// We only update the info if browsing the live workspace
if ($this->whichWorkspace() === 0 && $this->page['SYS_LASTCHANGED'] < (int)$this->register['SYS_LASTCHANGED']) {
$connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
$connection->update(
......
......@@ -72,9 +72,6 @@
<trans-unit id="shortcut_onlineWS">
<source>LIVE workspace</source>
</trans-unit>
<trans-unit id="shortcut_offlineWS">
<source>Draft workspace</source>
</trans-unit>
<trans-unit id="shortcut_active">
<source>active</source>
</trans-unit>
......@@ -159,9 +156,6 @@
<trans-unit id="bookmark_onlineWS">
<source>LIVE workspace</source>
</trans-unit>
<trans-unit id="bookmark_offlineWS">
<source>Draft workspace</source>
</trans-unit>
<trans-unit id="bookmark_active">
<source>active</source>
</trans-unit>
......
......@@ -20,7 +20,6 @@ use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\RootLevelRestriction;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
/**
* Hook for checking if the preview mode is activated
......@@ -64,7 +63,7 @@ class PreviewHook implements \TYPO3\CMS\Core\SingletonInterface
{
$this->previewConfiguration = $this->getPreviewConfiguration();
// if there is a valid BE user, and the full workspace should be previewed, the workspacePreview option should be set
$workspaceUid = $this->previewConfiguration['fullWorkspace'];
$workspaceUid = (int)$this->previewConfiguration['fullWorkspace'];
$workspaceRecord = null;
if ($this->previewConfiguration['BEUSER_uid'] > 0) {
// First initialize a temp user object and resolve usergroup information
......@@ -127,18 +126,16 @@ class PreviewHook implements \TYPO3\CMS\Core\SingletonInterface
}
if ($pObj->isBackendUserLoggedIn()
&& is_object($params['BE_USER'])
&& MathUtility::canBeInterpretedAsInteger($workspaceUid)
&& $workspaceUid > 0
) {
if ($workspaceUid == 0
|| $workspaceUid >= -1
&& $params['BE_USER']->checkWorkspace($workspaceRecord ?: $workspaceUid)
// Check Access to workspace
if ($params['BE_USER']->checkWorkspace($workspaceRecord ?: $workspaceUid)
&& $params['BE_USER']->isInWebMount($pObj->id)
) {
// Check Access to workspace. Live (0) is OK to preview for all.
$pObj->workspacePreview = (int)$workspaceUid;
} else {
// No preview, will default to "Live" at the moment
$pObj->workspacePreview = -99;
// No preview, will fallback to "Live" at the moment
$pObj->workspacePreview = 0;
}
}
}
......@@ -305,7 +302,7 @@ class PreviewHook implements \TYPO3\CMS\Core\SingletonInterface
*
* @param string $backendUserUid 32 byte MD5 hash keyword for the URL: "?ADMCMD_prev=[keyword]
* @param int $ttl Time-To-Live for keyword
* @param int|null $fullWorkspace Which workspace to preview. Workspace UID, -1 or >0. If set, the getVars is ignored in the frontend, so that string can be empty
* @param int|null $fullWorkspace Which workspace ID to preview.
* @return string Returns keyword to use in URL for ADMCMD_prev=
*/
public function compilePreviewKeyword($backendUserUid, $ttl = 172800, $fullWorkspace = null)
......
......@@ -68,13 +68,13 @@ class TypoScriptFrontendControllerHook
$content .= sprintf(
$pObj->config['config']['message_preview_workspace'],
$currentWorkspaceTitle,
$currentWorkspaceId ?? -1
$currentWorkspaceId ?? -99
);
} else {
$text = LocalizationUtility::translate(
'LLL:EXT:workspaces/Resources/Private/Language/locallang_mod.xlf:previewText',
'workspaces',
[$currentWorkspaceTitle, $currentWorkspaceId ?? -1]
[$currentWorkspaceTitle, $currentWorkspaceId ?? -99]
);
if ($pObj->doWorkspacePreview()) {
$urlForStoppingPreview = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'index.php?ADMCMD_prev=LOGOUT&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
......
......@@ -145,7 +145,7 @@ class WorkspaceService implements SingletonInterface
{
$wsid = (int)$wsid;
$cmd = [];
if ($wsid >= -1 && $wsid !== 0) {
if ($wsid > 0) {
// Define stage to select:
$stage = -99;
if ($wsid > 0) {
......@@ -180,7 +180,7 @@ class WorkspaceService implements SingletonInterface
{
$wsid = (int)$wsid;
$cmd = [];
if ($wsid >= -1 && $wsid !== 0) {
if ($wsid > 0) {
// Define stage to select:
$stage = -99;
// Select all versions to swap:
......
......@@ -402,9 +402,6 @@
<trans-unit id="label_onlymychanges">
<source>Show only my changes</source>
</trans-unit>
<trans-unit id="label_offlineWSes">
<source>Draft workspaces</source>
</trans-unit>
<trans-unit id="label_allWSes">
<source>All workspaces</source>
</trans-unit>
......
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