From 3a5a06304db51796bed40e8c97a40a6f09abea11 Mon Sep 17 00:00:00 2001
From: Elmar Hinz <t3elmar@gmail.com>
Date: Tue, 23 May 2017 16:50:58 +0200
Subject: [PATCH] [TASK] Protect internal properties of PageRepository

Mark the public properties as protected and deprecate them within
PageRepository:

- workspaceCache
- error_getRootLine
- error_getRootLine_failPid

Change-Id: I4ed101794dcfc7fa054d42d9e58ad8b5718bcc5d
Releases: master
Resolves: #81318
Reviewed-on: https://review.typo3.org/52918
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
---
 ...81318-PublicPropertiesOfPageRepository.rst | 39 +++++++++++++++++++
 .../frontend/Classes/Page/PageRepository.php  | 18 +++++++--
 .../Php/PropertyPublicMatcher.php             | 15 +++++++
 3 files changed, 69 insertions(+), 3 deletions(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-81318-PublicPropertiesOfPageRepository.rst

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-81318-PublicPropertiesOfPageRepository.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-81318-PublicPropertiesOfPageRepository.rst
new file mode 100644
index 000000000000..c911a13dfacd
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-81318-PublicPropertiesOfPageRepository.rst
@@ -0,0 +1,39 @@
+.. include:: ../../Includes.txt
+
+=========================================================
+Deprecation: #81318 - Public properties of PageRepository
+=========================================================
+
+See :issue:`81318`
+
+Description
+===========
+
+The following properties within the PageRepository PHP class have been marked as deprecated, as they
+were moved from public access to protected access:
+
+* workspaceCache
+* error_getRootLine
+* error_getRootLine_failPid
+
+They should only be accessed from within the PHP class itself.
+
+
+Impact
+======
+
+Accessing any of the properties directly within PHP will trigger a deprecation warning.
+
+
+Affected Installations
+======================
+
+Extensions accessing one of the previously public properties directly.
+
+
+Migration
+=========
+
+Remove the PHP calls and either extend the PHP class to your own needs or avoid accessing these properties.
+
+.. index:: PHP-API, FullyScanned
\ No newline at end of file
diff --git a/typo3/sysext/frontend/Classes/Page/PageRepository.php b/typo3/sysext/frontend/Classes/Page/PageRepository.php
index 269de786bfda..56a8cb117c43 100644
--- a/typo3/sysext/frontend/Classes/Page/PageRepository.php
+++ b/typo3/sysext/frontend/Classes/Page/PageRepository.php
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Frontend\Page;
 
 use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerAwareTrait;
+use TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryHelper;
@@ -41,6 +42,17 @@ use TYPO3\CMS\Core\Versioning\VersionState;
 class PageRepository implements LoggerAwareInterface
 {
     use LoggerAwareTrait;
+    use PublicPropertyDeprecationTrait;
+
+    /**
+     * List of all deprecated public properties
+     * @var array
+     */
+    protected $deprecatedPublicProperties = [
+        'workspaceCache' => 'Using $workspaceCache from the outside is discouraged, as this only reflects a local runtime cache.',
+        'error_getRootLine' => 'Using $error_getRootLine from the outside is deprecated as this property only exists for legacy reasons.',
+        'error_getRootLine_failPid' => 'Using $error_getRootLine_failPid from the outside is deprecated as this property only exists for legacy reasons.',
+    ];
 
     /**
      * This is not the final clauses. There will normally be conditions for the
@@ -82,21 +94,21 @@ class PageRepository implements LoggerAwareInterface
     /**
      * @var array
      */
-    public $workspaceCache = [];
+    protected $workspaceCache = [];
 
     /**
      * Error string set by getRootLine()
      *
      * @var string
      */
-    public $error_getRootLine = '';
+    protected $error_getRootLine = '';
 
     /**
      * Error uid set by getRootLine()
      *
      * @var int
      */
-    public $error_getRootLine_failPid = 0;
+    protected $error_getRootLine_failPid = 0;
 
     /**
      * @var array
diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php
index 7081430685c9..39099230fb56 100644
--- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php
+++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php
@@ -221,4 +221,19 @@ return [
     ],
 
     // Deprecated public properties
+    'TYPO3\CMS\Frontend\Page\PageRepository->workspaceCache' => [
+        'restFiles' => [
+            'Deprecation-81318-PublicPropertiesOfPageRepository.rst',
+        ],
+    ],
+    'TYPO3\CMS\Frontend\Page\PageRepository->error_getRootLine' => [
+        'restFiles' => [
+            'Deprecation-81318-PublicPropertiesOfPageRepository.rst',
+        ],
+    ],
+    'TYPO3\CMS\Frontend\Page\PageRepository->error_getRootLine_failPid' => [
+        'restFiles' => [
+            'Deprecation-81318-PublicPropertiesOfPageRepository.rst',
+        ],
+    ],
 ];
-- 
GitLab