[TASK] Deprecate class FE_loadDBGroup 49/18549/5
authorThorsten Kahler <thorsten.kahler@typo3.org>
Fri, 1 Mar 2013 11:17:04 +0000 (12:17 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 19 Mar 2013 19:14:38 +0000 (20:14 +0100)
Class FE_loadDBGroup's only purpose is to set an attribute of its parent
class. This should better be done when instantiating an object.

This patch additionaly renames the mentioned attribute to make its
purpose clearer. A setter method for that attribute is added and a
compatibility layer as well.

Change-Id: I44b3e331dcb86d75f266d9e36cf0829998f1fb5b
Resolves: #45937
Related: #23977
Releases: 6.1
Reviewed-on: https://review.typo3.org/18549
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/cms/tslib/class.tslib_pagegen.php
typo3/sysext/core/Classes/Database/RelationHandler.php
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php
typo3/sysext/sys_action/Classes/ActionTask.php

index 6e088be..153a147 100644 (file)
@@ -10,15 +10,24 @@ require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('fronte
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  * @see tslib_cObj::RECORDS()
+ * @deprecated since 6.1 will be removed in 6.3
  */
 class FE_loadDBGroup extends \TYPO3\CMS\Core\Database\RelationHandler {
 
-       // Means that everything is returned instead of only uid and label-field
        /**
-        * @todo Define visibility
+        * @var boolean $fetchAllFields if false getFromDB() fetches only uid, pid, thumbnail and label fields (as defined in TCA)
         */
-       public $fromTC = 0;
+       public $fetchAllFields = TRUE;
+
+       /**
+        * Default constructor writes deprecation log.
+        */
+       public function __construct() {
+               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                       'Class FE_loadDBGroup is deprecated and unused since TYPO3 6.1. It will be removed with version 6.3.'
+               );
+       }
 
 }
 
-?>
\ No newline at end of file
+?>
index 1e3b1e3..e29f7a4 100644 (file)
@@ -41,12 +41,10 @@ namespace TYPO3\CMS\Core\Database;
  */
 class RelationHandler {
 
-       // External, static
-       // Means that only uid and the label-field is returned
        /**
-        * @todo Define visibility
+        * @var boolean $fetchAllFields if false getFromDB() fetches only uid, pid, thumbnail and label fields (as defined in TCA)
         */
-       public $fromTC = 1;
+       protected $fetchAllFields = FALSE;
 
        // If set, values that are not ids in tables are normally discarded. By this options they will be preserved.
        /**
@@ -253,6 +251,32 @@ class RelationHandler {
        }
 
        /**
+        * Magic setter method.
+        * Used for compatibility with changed attribute visibility
+        *
+        * @param string $name name of the attribute
+        * @param mixed $value value to set the attribute to
+        * @deprecated since 6.1, only required as compatibility layer for renamed attribute $fromTC
+        */
+       public function __set($name, $value) {
+               if($name === 'fromTC') {
+                       \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+                               '$fromTC is protected since TYPO3 6.1. Use setFetchAllFields() instead!'
+                       );
+                       $this->setFetchAllFields(!$value);
+               }
+       }
+
+       /**
+        * Sets $fetchAllFields
+        *
+        * @param boolean $allFields enables fetching of all fields in getFromDB()
+        */
+       public function setFetchAllFields($allFields) {
+               $this->fetchAllFields = (bool)$allFields;
+       }
+
+       /**
         * Sets whether the reference index shall be updated.
         *
         * @param boolean $updateReferenceIndex Whether the reference index shall be updated
@@ -805,7 +829,7 @@ class RelationHandler {
 
        /**
         * Reads all records from internal tableArray into the internal ->results array where keys are table names and for each table, records are stored with uids as their keys.
-        * If $this->fromTC is set you can save a little memory since only uid,pid and a few other fields are selected.
+        * If $this->fetchAllFields is false you can save a little memory since only uid,pid and a few other fields are selected.
         *
         * @return      void
         * @todo Define visibility
@@ -816,8 +840,9 @@ class RelationHandler {
                        if (is_array($val)) {
                                $itemList = implode(',', $val);
                                if ($itemList) {
-                                       $from = '*';
-                                       if ($this->fromTC) {
+                                       if ($this->fetchAllFields) {
+                                               $from = '*';
+                                       } else {
                                                $from = 'uid,pid';
                                                if ($GLOBALS['TCA'][$key]['ctrl']['label']) {
                                                        // Titel
@@ -918,4 +943,4 @@ class RelationHandler {
 }
 
 
-?>
\ No newline at end of file
+?>
index aa11a7c..8de381b 100644 (file)
@@ -479,7 +479,9 @@ class AbstractMenuContentObject {
                                        if ($value == '') {
                                                $value = $this->id;
                                        }
-                                       $loadDB = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('FE_loadDBGroup');
+                                       /** @var \TYPO3\CMS\Core\Database\RelationHandler $loadDB*/
+                                       $loadDB = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler');
+                                       $loadDB->setFetchAllFields(TRUE);
                                        $loadDB->start($value, 'pages');
                                        $loadDB->additionalWhere['pages'] = \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::enableFields('pages');
                                        $loadDB->getFromDB();
@@ -1784,4 +1786,4 @@ class AbstractMenuContentObject {
 }
 
 
-?>
\ No newline at end of file
+?>
index f3c9d3f..a1a4350 100644 (file)
@@ -60,7 +60,9 @@ class RecordsContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractCon
                                        }
                                }
                        }
-                       $loadDB = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('FE_loadDBGroup');
+                       /** @var \TYPO3\CMS\Core\Database\RelationHandler $loadDB*/
+                       $loadDB = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler');
+                       $loadDB->setFetchAllFields(TRUE);
                        $loadDB->start($source, $allowedTables);
                        foreach ($loadDB->tableArray as $table => $v) {
                                if (is_array($GLOBALS['TCA'][$table])) {
@@ -122,4 +124,4 @@ class RecordsContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractCon
 }
 
 
-?>
\ No newline at end of file
+?>
index dbb9c87..b700310 100644 (file)
@@ -646,7 +646,7 @@ class ActionTask implements \TYPO3\CMS\Taskcenter\TaskInterface {
                $content = '';
                $actionList = array();
                $dbAnalysis = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler');
-               $dbAnalysis->fromTC = 0;
+               $dbAnalysis->setFetchAllFields(TRUE);
                $dbAnalysis->start($record['t4_recordsToEdit'], '*');
                $dbAnalysis->getFromDB();
                // collect the records