diff --git a/typo3/sysext/core/Classes/Database/Query/Restriction/FrontendWorkspaceRestriction.php b/typo3/sysext/core/Classes/Database/Query/Restriction/FrontendWorkspaceRestriction.php
index dc724a8f20fa6922268b99d91a5eac2fed7d7106..0252e7e249f2aa498e512957bd4a456d06e8e71d 100644
--- a/typo3/sysext/core/Classes/Database/Query/Restriction/FrontendWorkspaceRestriction.php
+++ b/typo3/sysext/core/Classes/Database/Query/Restriction/FrontendWorkspaceRestriction.php
@@ -15,8 +15,10 @@ namespace TYPO3\CMS\Core\Database\Query\Restriction;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;
 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
 
 /**
@@ -46,8 +48,9 @@ class FrontendWorkspaceRestriction implements QueryRestrictionInterface
      */
     public function __construct(int $workspaceId = null, bool $includeRowsForWorkspacePreview = null, bool $enforceLiveRowsOnly = true)
     {
-        $this->workspaceId = $workspaceId ?? $GLOBALS['TSFE']->sys_page->versioningWorkspaceId;
-        $this->includeRowsForWorkspacePreview = $includeRowsForWorkspacePreview ?? $GLOBALS['TSFE']->sys_page->versioningWorkspaceId > 0;
+        $globalWorkspaceId = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('workspace', 'id');
+        $this->workspaceId = $workspaceId ?? $globalWorkspaceId;
+        $this->includeRowsForWorkspacePreview = $includeRowsForWorkspacePreview ?? $globalWorkspaceId > 0;
         $this->enforceLiveRowsOnly = $enforceLiveRowsOnly;
     }
 
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85556-PageRepository-versioningWorkspaceId.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85556-PageRepository-versioningWorkspaceId.rst
new file mode 100644
index 0000000000000000000000000000000000000000..c67def9aa6c962d1ff5134746125304cf5cf1614
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85556-PageRepository-versioningWorkspaceId.rst
@@ -0,0 +1,38 @@
+.. include:: ../../Includes.txt
+
+===========================================================
+Deprecation: #85556 - PageRepository->versioningWorkspaceId
+===========================================================
+
+See :issue:`85556`
+
+Description
+===========
+
+The public property :php:`TYPO3\CMS\Frontend\Page\PageRepository->versioningWorkspaceId` has been marked as
+deprecated.
+
+
+Impact
+======
+
+Accessing or setting the property directly will trigger a deprecation message.
+
+
+Affected Installations
+======================
+
+TYPO3 installations with custom extensions calling this public property directly.
+
+
+Migration
+=========
+
+Use the Context API and its workspace aspect
+
+:php:`GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('workspace', 'id', 0);`
+
+directly when reading the workspace ID, or instantiate a custom PageRepository with a custom context (see Context
+API docs) for custom usages.
+
+.. index:: Frontend, PHP-API, FullyScanned, ext:frontend
\ No newline at end of file
diff --git a/typo3/sysext/core/Tests/Unit/Database/Query/Restriction/FrontendWorkspaceRestrictionTest.php b/typo3/sysext/core/Tests/Unit/Database/Query/Restriction/FrontendWorkspaceRestrictionTest.php
index 1f2a73248b0cedfd70b2c5d0f947f74d477c2427..671e0f0ed216fec3f4592084336cb895da2fea73 100644
--- a/typo3/sysext/core/Tests/Unit/Database/Query/Restriction/FrontendWorkspaceRestrictionTest.php
+++ b/typo3/sysext/core/Tests/Unit/Database/Query/Restriction/FrontendWorkspaceRestrictionTest.php
@@ -16,10 +16,14 @@ namespace TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction;
  */
 
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendWorkspaceRestriction;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
+/**
+ * Test case
+ */
 class FrontendWorkspaceRestrictionTest extends AbstractRestrictionTestCase
 {
+    protected $resetSingletonInstances = true;
+
     /**
      * @test
      */
@@ -33,12 +37,6 @@ class FrontendWorkspaceRestrictionTest extends AbstractRestrictionTestCase
             ]
         ];
 
-        $pageRepository = $this->createMock(PageRepository::class);
-        $pageRepository->versioningWorkspaceId = 0;
-
-        $GLOBALS['TSFE'] = new \stdClass();
-        $GLOBALS['TSFE']->sys_page = $pageRepository;
-
         $subject = new FrontendWorkspaceRestriction(0);
         $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
         $this->assertSame('("aTable"."t3ver_state" <= 0) AND ("aTable"."pid" <> -1)', (string)$expression);
@@ -57,9 +55,6 @@ class FrontendWorkspaceRestrictionTest extends AbstractRestrictionTestCase
             ]
         ];
 
-        $pageRepository = $this->createMock(PageRepository::class);
-        $pageRepository->versioningWorkspaceId = 42;
-
         $subject = new FrontendWorkspaceRestriction(42, true);
         $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
         $this->assertSame('(("aTable"."t3ver_wsid" = 0) OR ("aTable"."t3ver_wsid" = 42)) AND ("aTable"."pid" <> -1)', (string)$expression);
@@ -78,9 +73,6 @@ class FrontendWorkspaceRestrictionTest extends AbstractRestrictionTestCase
             ]
         ];
 
-        $pageRepository = $this->createMock(PageRepository::class);
-        $pageRepository->versioningWorkspaceId = 42;
-
         $subject = new FrontendWorkspaceRestriction(42, true, false);
         $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
         $this->assertSame('("aTable"."t3ver_wsid" = 0) OR ("aTable"."t3ver_wsid" = 42)', (string)$expression);
diff --git a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php
index 8d54e36d3f6b5d7a04678bb90e3a0ee2d2efeaa4..9afec93e08a7d5d96aa3a191813e7439b898533f 100644
--- a/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php
+++ b/typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php
@@ -161,16 +161,15 @@ class Typo3DbBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
             ->disableOriginalConstructor()
             ->getMock();
         $sourceMock = new \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Selector('tx_foo', 'Tx_Foo');
+        $context = new Context([
+            'workspace' => new WorkspaceAspect($workspaceUid)
+        ]);
         /** @var $pageRepositoryMock PageRepository|\PHPUnit_Framework_MockObject_MockObject */
         $pageRepositoryMock = $this->getMockBuilder(PageRepository::class)
             ->setMethods(['movePlhOL', 'getWorkspaceVersionOfRecord'])
-            ->disableOriginalConstructor()
+            ->setConstructorArgs([$context])
             ->getMock();
         $pageRepositoryMock->expects($this->once())->method('getWorkspaceVersionOfRecord')->with($workspaceUid, 'tx_foo', '42')->will($this->returnValue($workspaceVersion));
-        $pageRepositoryMock->versioningWorkspaceId = $workspaceUid;
-        $context = new Context([
-            'workspace' => new WorkspaceAspect($workspaceUid)
-        ]);
         $objectManagerMock->expects($this->at(0))->method('get')->with(Context::class)->willReturn($context);
         $objectManagerMock->expects($this->at(1))->method('get')->with(PageRepository::class, $context)->willReturn($pageRepositoryMock);
         $mockTypo3DbBackend = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::class, ['dummy'], [], '', false);
diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
index 358916812d9c0bd3e9f25642f9bad7f4c18a718a..e7c9e22685e1e07ff7cea1cdb179f21079a8ae39 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
@@ -6723,8 +6723,9 @@ class ContentObjectRenderer implements LoggerAwareInterface
             'orderBy' => null,
         ];
 
+        $isInWorkspace = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('workspace', 'isOffline');
         $considerMovePlaceholders = (
-            $tsfe->sys_page->versioningWorkspaceId > 0 && $table !== 'pages'
+            $isInWorkspace && $table !== 'pages'
             && !empty($GLOBALS['TCA'][$table]['ctrl']['versioningWS'])
         );
 
diff --git a/typo3/sysext/frontend/Classes/Page/PageRepository.php b/typo3/sysext/frontend/Classes/Page/PageRepository.php
index 1a94990d2d24b5750bfdbbfd2c7f97e8ee1fd0d9..c6671427db17f073a23da4b159ef7719cc14bad1 100644
--- a/typo3/sysext/frontend/Classes/Page/PageRepository.php
+++ b/typo3/sysext/frontend/Classes/Page/PageRepository.php
@@ -58,6 +58,7 @@ class PageRepository implements LoggerAwareInterface
         'error_getRootLine' => 'Using $error_getRootLine of class PageRepository from the outside is deprecated as this property only exists for legacy reasons.',
         'error_getRootLine_failPid' => 'Using $error_getRootLine_failPid of class PageRepository from the outside is deprecated as this property only exists for legacy reasons.',
         'sys_language_uid' => 'Using $sys_language_uid of class PageRepository from the outside is deprecated as this information is now stored within the Context Language Aspect given by the constructor.',
+        'versioningWorkspaceId' => 'Using $versioningWorkspaceId of class PageRepository from the outside is deprecated as this information is now stored within the Context Workspace Aspect given by the constructor.',
     ];
 
     /**
@@ -100,8 +101,9 @@ class PageRepository implements LoggerAwareInterface
      * user!
      *
      * @var int
+     * @deprecated This method will be kept protected from TYPO3 v10.0 on, instantiate a new pageRepository object with a custom workspace aspect to override this setting.
      */
-    public $versioningWorkspaceId = 0;
+    protected $versioningWorkspaceId = 0;
 
     /**
      * @var array
diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php
index 102cd9a993d876554f5859c6f7c98aed69d10f64..37d76364a286ebd1f5d18714b51c0d9cf7195e95 100644
--- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php
+++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php
@@ -461,6 +461,11 @@ return [
             'Deprecation-85543-Language-relatedPropertiesInTypoScriptFrontendControllerAndPageRepository.rst'
         ],
     ],
+    'TYPO3\CMS\Frontend\Page\PageRepository->versioningWorkspaceId' => [
+        'restFiles' => [
+            'Deprecation-85556-PageRepository-versioningWorkspaceId.rst'
+        ],
+    ],
     'TYPO3\CMS\Core\TypoScript\TemplateService->fileCache' => [
         'restFiles' => [
             'Deprecation-85445-TemplateService-getFileName.rst'