From cf7e0a2e795fac9293be0fdbdebcdfb056053afc Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Mon, 27 Mar 2017 16:13:27 +0200
Subject: [PATCH] [TASK] Deprecate TSFE->whichWorkspace parameter

The parameter of the $TSFE->whichWorkspace() method decides
whether the UID of the current workspace should be returned or
the actual "title" of the sys_workspace record.

As this parameter is not in use anymore and clearly makes this function
harder to understand why and when someone could use this, this property
is marked as deprecated.

Instead, fetching the workspace title should happen in the place where it
is needed.

Resolves: #80485
Releases: master
Change-Id: I06512e40c48b35826c0d0a89cc8c4cdcdc8773e6
Reviewed-on: https://review.typo3.org/52184
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
---
 ...hichWorkspaceToReturnTheWorkspaceTitle.rst | 39 +++++++++++++++++++
 .../TypoScriptFrontendController.php          |  3 +-
 2 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-80485-MethodParameterOfTSFE-whichWorkspaceToReturnTheWorkspaceTitle.rst

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80485-MethodParameterOfTSFE-whichWorkspaceToReturnTheWorkspaceTitle.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80485-MethodParameterOfTSFE-whichWorkspaceToReturnTheWorkspaceTitle.rst
new file mode 100644
index 000000000000..26f2e66457df
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80485-MethodParameterOfTSFE-whichWorkspaceToReturnTheWorkspaceTitle.rst
@@ -0,0 +1,39 @@
+.. include:: ../../Includes.txt
+
+============================================================================================
+Deprecation: #80485 - Method parameter of TSFE->whichWorkspace to return the workspace title
+============================================================================================
+
+See :issue:`80485`
+
+Description
+===========
+
+The method php::`TypoScriptFrontendController->whichWorkspace()` has an optional first parameter
+to return the workspace title of the current workspace instead of the current workspace UID.
+
+This parameter has been marked as deprecated.
+
+
+Impact
+======
+
+When calling the method above with the method parameter set to "true", a deprecation message is
+triggered.
+
+
+Affected Installations
+======================
+
+Any installation using this PHP method with the parameter set to "true" via a custom extension which
+deals with workspaces for frontend output (e.g. for editors to know in which workspace a user is 
+currently previewing a page).
+
+
+Migration
+=========
+
+If the workspace title is necessary, a separate SQL call should be done right after
+`whichWorkspace()` is called in the extensions' PHP code.
+
+.. index:: Frontend, PHP-API
\ No newline at end of file
diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
index fcb0ec1c614f..3d969597343c 100644
--- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
+++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
@@ -4124,7 +4124,7 @@ class TypoScriptFrontendController
     /**
      * Returns the name of the workspace
      *
-     * @param bool $returnTitle If set, returns title of current workspace being previewed
+     * @param bool $returnTitle If set, returns title of current workspace being previewed, please be aware that this parameter is deprecated as of TYPO3 v8, and will be removed in TYPO3 v9
      * @return string|int|NULL If $returnTitle is set, returns string (title), otherwise workspace integer for which workspace is being preview. NULL if none.
      */
     public function whichWorkspace($returnTitle = false)
@@ -4136,6 +4136,7 @@ class TypoScriptFrontendController
             $ws = $this->getBackendUser()->workspace;
         }
         if ($ws && $returnTitle) {
+            GeneralUtility::deprecationLog('The parameter $returnTitle of $TSFE->whichWorkspace() is marked as deprecated and has no effect anymore. It will be removed in TYPO3 v9.');
             if (ExtensionManagementUtility::isLoaded('workspaces')) {
                 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
                     ->getQueryBuilderForTable('sys_workspace');
-- 
GitLab