[TASK] Deprecate cObj->enableFields() 98/57598/3
authorBenni Mack <benni@typo3.org>
Fri, 13 Jul 2018 21:04:09 +0000 (23:04 +0200)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Thu, 19 Jul 2018 22:41:18 +0000 (00:41 +0200)
The method is just a wrapper for PageRepository->enableFields()
which should be used instead.

Resolves: #85558
Releases: master
Change-Id: I5fd18ef3e101325bc95f4d0147899d961f5898f6
Reviewed-on: https://review.typo3.org/57598
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
typo3/sysext/core/Documentation/Changelog/master/Deprecation-85558-ContentObjectRenderer-enableFields.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85558-ContentObjectRenderer-enableFields.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85558-ContentObjectRenderer-enableFields.rst
new file mode 100644 (file)
index 0000000..8a75814
--- /dev/null
@@ -0,0 +1,34 @@
+.. include:: ../../Includes.txt
+
+=========================================================
+Deprecation: #85558 - ContentObjectRenderer->enableFields
+=========================================================
+
+See :issue:`85558`
+
+Description
+===========
+
+The public method :php:`TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->enableFields` has been marked as
+deprecated.
+
+
+Impact
+======
+
+Calling the method directly will trigger a deprecation message.
+
+
+Affected Installations
+======================
+
+TYPO3 installations with custom extensions calling this method directly.
+
+
+Migration
+=========
+
+As :php:`enableFields()` acts as a simple wrapper around :php:`PageRepository->enableFields()`, it is recommended
+to instantiate PageRepository directly.
+
+.. index:: Frontend, PHP-API, FullyScanned, ext:frontend
\ No newline at end of file
index c2c3d2e..3589168 100644 (file)
@@ -6064,9 +6064,11 @@ class ContentObjectRenderer implements LoggerAwareInterface
      * @param bool $show_hidden If set, then you want NOT to filter out hidden records. Otherwise hidden record are filtered based on the current preview settings.
      * @param array $ignore_array Array you can pass where keys can be "disabled", "starttime", "endtime", "fe_group" (keys from "enablefields" in TCA) and if set they will make sure that part of the clause is not added. Thus disables the specific part of the clause. For previewing etc.
      * @return string The part of the where clause on the form " AND [fieldname]=0 AND ...". Eg. " AND hidden=0 AND starttime < 123345567
+     * @deprecated since TYPO3 v9.4, will be removed in TYPO3 v10.0.
      */
     public function enableFields($table, $show_hidden = false, array $ignore_array = [])
     {
+        trigger_error('cObj->enableFields() will be removed in TYPO3 v10. should be used from the PageRepository->enableFields() functionality directly.', E_USER_DEPRECATED);
         return $this->getTypoScriptFrontendController()->sys_page->enableFields($table, $show_hidden ? true : -1, $ignore_array);
     }
 
@@ -6825,7 +6827,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
             $constraints[] = QueryHelper::stripLogicalOperatorPrefix($tsfe->sys_page->where_hid_del);
             $constraints[] = QueryHelper::stripLogicalOperatorPrefix($tsfe->sys_page->where_groupAccess);
         } else {
-            $constraints[] = QueryHelper::stripLogicalOperatorPrefix($this->enableFields($table, false, $enableFieldsIgnore));
+            $constraints[] = QueryHelper::stripLogicalOperatorPrefix($tsfe->sys_page->enableFields($table, -1, $enableFieldsIgnore));
         }
 
         // MAKE WHERE:
index 9690f92..3ff5e80 100644 (file)
@@ -798,7 +798,7 @@ abstract class AbstractMenuContentObject
         $loadDB = GeneralUtility::makeInstance(RelationHandler::class);
         $loadDB->setFetchAllFields(true);
         $loadDB->start($specialValue, 'pages');
-        $loadDB->additionalWhere['pages'] = $this->parent_cObj->enableFields('pages', false, $skippedEnableFields);
+        $loadDB->additionalWhere['pages'] = $this->sys_page->enableFields('pages', -1, $skippedEnableFields);
         $loadDB->getFromDB();
         $pageLinkBuilder = GeneralUtility::makeInstance(PageLinkBuilder::class, $this->parent_cObj);
         foreach ($loadDB->itemArray as $val) {
index 979060c..d6d72d8 100644 (file)
@@ -18,6 +18,7 @@ use TYPO3\CMS\Core\Database\RelationHandler;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Category\Collection\CategoryCollection;
+use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Contains RECORDS class object.
@@ -92,10 +93,10 @@ class RecordsContentObject extends AbstractContentObject
                     // Perform overlays if necessary (records coming from category collections are already overlaid)
                     if ($source) {
                         // Versioning preview
-                        $GLOBALS['TSFE']->sys_page->versionOL($val['table'], $row);
+                        $this->getPageRepository()->versionOL($val['table'], $row);
                         // Language overlay
                         if (is_array($row)) {
-                            $row = $GLOBALS['TSFE']->sys_page->getLanguageOverlay($val['table'], $row);
+                            $row = $this->getPageRepository()->getLanguageOverlay($val['table'], $row);
                         }
                     }
                     // Might be unset during the overlay process
@@ -149,7 +150,7 @@ class RecordsContentObject extends AbstractContentObject
         $loadDB->start($source, implode(',', $tables));
         foreach ($loadDB->tableArray as $table => $v) {
             if (isset($GLOBALS['TCA'][$table])) {
-                $loadDB->additionalWhere[$table] = $this->cObj->enableFields($table);
+                $loadDB->additionalWhere[$table] = $this->getPageRepository()->enableFields($table);
             }
         }
         $this->data = $loadDB->getFromDB();
@@ -226,4 +227,12 @@ class RecordsContentObject extends AbstractContentObject
     {
         return GeneralUtility::makeInstance(TimeTracker::class);
     }
+
+    /**
+     * @return PageRepository
+     */
+    protected function getPageRepository(): PageRepository
+    {
+        return $GLOBALS['TSFE']->sys_page ?: GeneralUtility::makeInstance(PageRepository::class);
+    }
 }
index 63d3294..7d98d5d 100644 (file)
@@ -2438,6 +2438,13 @@ return [
             'Deprecation-85555-TypoScriptFrontendController-getUniqueId.rst',
         ],
     ],
+    'TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->enableFields' => [
+        'numberOfMandatoryArguments' => 1,
+        'maximumNumberOfArguments' => 3,
+        'restFiles' => [
+            'Deprecation-85558-ContentObjectRenderer-enableFields.rst'
+        ],
+    ],
     'TYPO3\CMS\Scheduler\Classes\Controller\SchedulerModuleController->addMessage' => [
         'numberOfMandatoryArguments' => 1,
         'maximumNumberOfArguments' => 2,