[!!!][TASK] Replace DataHandler->exclude_array with key-based array 15/35315/11
authorStephan Großberndt <stephan@grossberndt.de>
Thu, 11 Dec 2014 17:57:22 +0000 (18:57 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Wed, 11 Mar 2015 18:47:17 +0000 (19:47 +0100)
Replace the public property array 'exclude_array' in DataHandler with a
protected property 'excludedTablesAndFields' using keys instead of
values. This change improves performance for bulk inserts since in
DataHandler->fillInFieldArray() many in_array()-checks can be avoided.

Resolves: #63784
Releases: master
Change-Id: I478319fea022c3eceaac35da9c093d1c43ecb2e4
Reviewed-on: http://review.typo3.org/35315
Reviewed-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Tested-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-63784-DataHandlerExcludeArray.rst [new file with mode: 0644]

index 87a13c4..6fcc6b2 100644 (file)
@@ -384,11 +384,11 @@ class DataHandler {
        );
 
        /**
-        * The list of <table>-<fields> that cannot be edited by user.This is compiled from TCA/exclude-flag combined with non_exclude_fields for the user.
+        * The list of <table>-<fields> that cannot be edited by user. This is compiled from TCA/exclude-flag combined with non_exclude_fields for the user.
         *
         * @var array
         */
-       public $exclude_array;
+       protected $excludedTablesAndFields = array();
 
        /**
         * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
@@ -709,7 +709,9 @@ class DataHandler {
                        $this->defaultPermissions['everybody'] = $defaultPermissions['everybody'];
                }
                // generates the excludelist, based on TCA/exclude-flag and non_exclude_fields for the user:
-               $this->exclude_array = $this->admin ? array() : $this->getExcludeListArray();
+               if (!$this->admin) {
+                       $this->excludedTablesAndFields = array_flip($this->getExcludeListArray());
+               }
                // Setting the data and cmd arrays
                if (is_array($data)) {
                        reset($data);
@@ -1320,7 +1322,7 @@ class DataHandler {
 
        /**
         * Filling in the field array
-        * $this->exclude_array is used to filter fields if needed.
+        * $this->excludedTablesAndFields is used to filter fields if needed.
         *
         * @param string $table Table name
         * @param int $id Record ID
@@ -1366,7 +1368,7 @@ class DataHandler {
                // - If the field is nothing of the above and the field is configured in TCA, the fieldvalues are evaluated by ->checkValue
                // If everything is OK, the field is entered into $fieldArray[]
                foreach ($incomingFieldArray as $field => $fieldValue) {
-                       if (!in_array(($table . '-' . $field), $this->exclude_array, TRUE) && !$this->data_disableFields[$table][$id][$field]) {
+                       if (!isset($this->excludedTablesAndFields[$table . '-' . $field]) && !$this->data_disableFields[$table][$id][$field]) {
                                // The field must be editable.
                                // Checking if a value for language can be changed:
                                $languageDeny = $GLOBALS['TCA'][$table]['ctrl']['languageField'] && (string)$GLOBALS['TCA'][$table]['ctrl']['languageField'] === (string)$field && !$this->BE_USER->checkLanguageAccess($fieldValue);
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-63784-DataHandlerExcludeArray.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-63784-DataHandlerExcludeArray.rst
new file mode 100644 (file)
index 0000000..f6eed32
--- /dev/null
@@ -0,0 +1,31 @@
+====================================================================
+Breaking: #63784 - Visibility and type of DataHandler->exclude_array
+====================================================================
+
+Description
+===========
+
+The internal but former public property DataHandler->exclude_array is replaced by
+the protected property DataHandler->excludedTablesAndFields, which contains the
+combination of excluded table and field as key instead. This improves performance
+especially for bulk editing since many in_array()-checks can be avoided.
+
+
+Impact
+======
+
+Extensions using the DataHandler (former TCEMain) and changing the (former public)
+exclude_array to change access to tables and fields cannot do so anymore. Instead
+the users need to have their access-rights set properly.
+
+
+Affected installations
+======================
+
+Installations using extensions that read or write the undocumented array exclude_array.
+
+
+Migration
+=========
+
+Remove code accessing DataHandler->exclude_array and configure the BE-User properly.
\ No newline at end of file