[TASK] Drop type=select neg_foreign_table 97/42597/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Thu, 13 Aug 2015 17:06:41 +0000 (19:06 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 13 Aug 2015 20:19:05 +0000 (22:19 +0200)
Drop the functionality to store relations to a second table
in type=select fields as negative uid values.

Resolves: #69028
Releases: master
Change-Id: Ifa4fab62ea01f4aae3647802a22518792f70f350
Reviewed-on: http://review.typo3.org/42597
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Controller/Wizard/EditController.php
typo3/sysext/backend/Classes/Form/DataPreprocessor.php
typo3/sysext/backend/Classes/Form/FlexFormsHelper.php
typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/Database/ReferenceIndex.php
typo3/sysext/core/Classes/Database/RelationHandler.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-24186-HTMLparser-FixAttribclasslistDoesNotAssignFirstElementWhenAttributeValueNotInList.rst
typo3/sysext/core/Documentation/Changelog/master/Breaking-69028-DropNegForeignTable.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Deprecation-69028-RelationHandlerConvertPosNeg.rst [new file with mode: 0644]

index a4caf76..e9c6288 100644 (file)
@@ -99,7 +99,7 @@ class EditController extends AbstractWizardController implements \TYPO3\CMS\Core
                $table = $this->P['table'];
                $field = $this->P['field'];
                $config = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
-               $fTable = $this->P['currentValue'] < 0 ? $config['neg_foreign_table'] : $config['foreign_table'];
+               $fTable = $config['foreign_table'];
 
                $urlParameters = array(
                        'returnUrl' => BackendUtility::getModuleUrl('wizard_edit', array('doClose' => 1))
@@ -115,7 +115,7 @@ class EditController extends AbstractWizardController implements \TYPO3\CMS\Core
                } elseif (is_array($config) && $this->P['currentSelectedValues'] && ($config['type'] === 'select' && $config['foreign_table'] || $config['type'] === 'group' && $config['internal_type'] === 'db')) {
                        // MULTIPLE VALUES:
                        // Init settings:
-                       $allowedTables = $config['type'] === 'group' ? $config['allowed'] : $config['foreign_table'] . ',' . $config['neg_foreign_table'];
+                       $allowedTables = $config['type'] === 'group' ? $config['allowed'] : $config['foreign_table'];
                        $prependName = 1;
                        // Selecting selected values into an array:
                        /** @var RelationHandler $relationHandler */
index a8f49b8..8ea347e 100644 (file)
@@ -735,16 +735,6 @@ class DataPreprocessor {
                        $recordList[$subrow['uid']] = BackendUtility::getRecordTitle($fieldConfig['config']['foreign_table'], $subrow);
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($subres);
-               // neg_foreign_table
-               if (is_array($GLOBALS['TCA'][$fieldConfig['config']['neg_foreign_table']])) {
-                       $subres = BackendUtility::exec_foreign_table_where_query($fieldConfig, $field, $TSconfig, 'neg_');
-                       while ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subres)) {
-                               // Resolve move-placeholder, to check the right uid against $dataIds
-                               BackendUtility::workspaceOL($fieldConfig['config']['neg_foreign_table'], $subrow);
-                               $recordList[-$subrow['uid']] = BackendUtility::getRecordTitle($fieldConfig['config']['neg_foreign_table'], $subrow);
-                       }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($subres);
-               }
                // At this point all records that CAN be selected is found in $recordList
                // Now, get the data from loadDBgroup based on the input list of values.
                $dataIds = $this->getDataIdList($elements, $fieldConfig, $row, $table);
@@ -755,7 +745,7 @@ class DataPreprocessor {
                // After this we can traverse the loadDBgroup values and match values with the list of possible values in $recordList:
                foreach ($dataIds as $theId) {
                        if (isset($recordList[$theId])) {
-                               $lPrefix = $languageService->sL($fieldConfig['config'][($theId > 0 ? '' : 'neg_') . 'foreign_table_prefix']);
+                               $lPrefix = $languageService->sL($fieldConfig['config']['foreign_table_prefix']);
                                if ($fieldConfig['config']['MM'] || $fieldConfig['config']['foreign_field']) {
                                        $dataAcc[] = rawurlencode($theId) . '|' . rawurlencode(GeneralUtility::fixed_lgd_cs(($lPrefix . strip_tags($recordList[$theId])), $GLOBALS['BE_USER']->uc['titleLen']));
                                } else {
@@ -789,8 +779,8 @@ class DataPreprocessor {
                }
                $loadDB = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\RelationHandler::class);
                $loadDB->registerNonTableValues = $fieldConfig['config']['allowNonIdValues'] ? 1 : 0;
-               $loadDB->start(implode(',', $elements), $fieldConfig['config']['foreign_table'] . ',' . $fieldConfig['config']['neg_foreign_table'], $fieldConfig['config']['MM'], $recordId, $table, $fieldConfig['config']);
-               $idList = $loadDB->convertPosNeg($loadDB->getValueArray(), $fieldConfig['config']['foreign_table'], $fieldConfig['config']['neg_foreign_table']);
+               $loadDB->start(implode(',', $elements), $fieldConfig['config']['foreign_table'], $fieldConfig['config']['MM'], $recordId, $table, $fieldConfig['config']);
+               $idList = $loadDB->getValueArray();
                return $idList;
        }
 
index 3b9a53c..fa2235f 100644 (file)
@@ -34,11 +34,6 @@ class FlexFormsHelper extends FormEngine {
                'foreign_table_where',
                'foreign_table_prefix',
                'foreign_table_loadIcons',
-               'neg_foreign_table',
-               'neg_foreign_table_where',
-               'neg_foreign_table_prefix',
-               'neg_foreign_table_loadIcons',
-               'neg_foreign_table_imposeValueField',
                'fileFolder',
                'fileFolder_extList',
                'fileFolder_recursions',
index 846ca24..63e1369 100644 (file)
@@ -416,9 +416,6 @@ class FormEngineUtility {
                // Values from foreign tables:
                if ($fieldValue['config']['foreign_table']) {
                        $items = static::foreignTable($items, $fieldValue, $TSconfig, $field);
-                       if ($fieldValue['config']['neg_foreign_table']) {
-                               $items = static::foreignTable($items, $fieldValue, $TSconfig, $field, 1);
-                       }
                }
 
                // Values from a file folder:
@@ -838,20 +835,17 @@ class FormEngineUtility {
         * @param array $fieldValue The 'columns' array for the field (from TCA)
         * @param array $TSconfig TSconfig for the table/row
         * @param string $field The fieldname
-        * @param bool $pFFlag If set, then we are fetching the 'neg_' foreign tables.
         * @return array The $items array modified.
         * @internal
         */
-       static protected function foreignTable($items, $fieldValue, $TSconfig, $field, $pFFlag = FALSE) {
+       static protected function foreignTable($items, $fieldValue, $TSconfig, $field) {
                $languageService = static::getLanguageService();
                $db = static::getDatabaseConnection();
 
                // Init:
-               $pF = $pFFlag ? 'neg_' : '';
-               $f_table = $fieldValue['config'][$pF . 'foreign_table'];
-               $uidPre = $pFFlag ? '-' : '';
+               $f_table = $fieldValue['config']['foreign_table'];
                // Exec query:
-               $res = BackendUtility::exec_foreign_table_where_query($fieldValue, $field, $TSconfig, $pF);
+               $res = BackendUtility::exec_foreign_table_where_query($fieldValue, $field, $TSconfig);
                // Perform error test
                if ($db->sql_error()) {
                        $msg = htmlspecialchars($db->sql_error());
@@ -868,7 +862,7 @@ class FormEngineUtility {
                        return array();
                }
                // Get label prefix.
-               $lPrefix = $languageService->sL($fieldValue['config'][$pF . 'foreign_table_prefix']);
+               $lPrefix = $languageService->sL($fieldValue['config']['foreign_table_prefix']);
                // Get icon field + path if any:
                $iField = $GLOBALS['TCA'][$f_table]['ctrl']['selicon_field'];
                $iPath = trim($GLOBALS['TCA'][$f_table]['ctrl']['selicon_field_path']);
@@ -888,7 +882,7 @@ class FormEngineUtility {
                                // Add the item:
                                $items[] = array(
                                        $lPrefix . htmlspecialchars(BackendUtility::getRecordTitle($f_table, $row)),
-                                       $uidPre . $row['uid'],
+                                       $row['uid'],
                                        $icon
                                );
                        }
index 631921c..eed405f 100755 (executable)
@@ -2294,13 +2294,9 @@ class BackendUtility {
                                                        $lA = array();
                                                        foreach ($rParts as $rVal) {
                                                                $rVal = (int)$rVal;
-                                                               if ($rVal > 0) {
-                                                                       $r = self::getRecordWSOL($theColConf['foreign_table'], $rVal);
-                                                               } else {
-                                                                       $r = self::getRecordWSOL($theColConf['neg_foreign_table'], -$rVal);
-                                                               }
+                                                               $r = self::getRecordWSOL($theColConf['foreign_table'], $rVal);
                                                                if (is_array($r)) {
-                                                                       $lA[] = $lang->sL(($rVal > 0 ? $theColConf['foreign_table_prefix'] : $theColConf['neg_foreign_table_prefix'])) . self::getRecordTitle(($rVal > 0 ? $theColConf['foreign_table'] : $theColConf['neg_foreign_table']), $r, FALSE, $forceResult);
+                                                                       $lA[] = $lang->sL($theColConf['foreign_table_prefix']) . self::getRecordTitle($theColConf['foreign_table'], $r, FALSE, $forceResult);
                                                                } else {
                                                                        $lA[] = $rVal ? '[' . $rVal . '!]' : '';
                                                                }
@@ -3444,14 +3440,13 @@ class BackendUtility {
         * @param array $fieldValue Configuration array for the field, taken from $GLOBALS['TCA']
         * @param string $field Field name
         * @param array $TSconfig TSconfig array from which to get further configuration settings for the field name
-        * @param string $prefix Prefix string for the key "*foreign_table_where" from $fieldValue array
         * @return string Part of query
         * @internal
         */
-       static public function exec_foreign_table_where_query($fieldValue, $field = '', $TSconfig = array(), $prefix = '') {
-               $foreign_table = $fieldValue['config'][$prefix . 'foreign_table'];
+       static public function exec_foreign_table_where_query($fieldValue, $field = '', $TSconfig = array()) {
+               $foreign_table = $fieldValue['config']['foreign_table'];
                $rootLevel = $GLOBALS['TCA'][$foreign_table]['ctrl']['rootLevel'];
-               $fTWHERE = $fieldValue['config'][$prefix . 'foreign_table_where'];
+               $fTWHERE = $fieldValue['config']['foreign_table_where'];
                $fTWHERE = static::replaceMarkersInWhereClause($fTWHERE, $foreign_table, $field, $TSconfig);
                $db = static::getDatabaseConnection();
                $wgolParts = $db->splitGroupOrderLimit($fTWHERE);
index 891bdef..56cd65c 100644 (file)
@@ -2891,8 +2891,8 @@ class DataHandler {
         * @return array Modified value array
         */
        public function checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, $type, $currentTable, $currentField) {
-               $tables = $type == 'group' ? $tcaFieldConf['allowed'] : $tcaFieldConf['foreign_table'] . ',' . $tcaFieldConf['neg_foreign_table'];
-               $prep = $type == 'group' ? $tcaFieldConf['prepend_tname'] : $tcaFieldConf['neg_foreign_table'];
+               $tables = $type == 'group' ? $tcaFieldConf['allowed'] : $tcaFieldConf['foreign_table'];
+               $prep = $type == 'group' ? $tcaFieldConf['prepend_tname'] : '';
                $newRelations = implode(',', $valueArray);
                /** @var $dbAnalysis RelationHandler */
                $dbAnalysis = $this->createRelationHandlerInstance();
@@ -2920,9 +2920,6 @@ class DataHandler {
                        $valueArray = $dbAnalysis->countItems();
                } else {
                        $valueArray = $dbAnalysis->getValueArray($prep);
-                       if ($type == 'select' && $prep) {
-                               $valueArray = $dbAnalysis->convertPosNeg($valueArray, $tcaFieldConf['foreign_table'], $tcaFieldConf['neg_foreign_table']);
-                       }
                }
                // Here we should see if 1) the records exist anymore, 2) which are new and check if the BE_USER has read-access to the new ones.
                return $valueArray;
@@ -3722,8 +3719,8 @@ class DataHandler {
         * @return mixed
         */
        protected function copyRecord_processManyToMany($table, $uid, $field, $value, $conf, $language, $localizationMode, $inlineSubType) {
-               $allowedTables = $conf['type'] == 'group' ? $conf['allowed'] : $conf['foreign_table'] . ',' . $conf['neg_foreign_table'];
-               $prependName = $conf['type'] == 'group' ? $conf['prepend_tname'] : $conf['neg_foreign_table'];
+               $allowedTables = $conf['type'] == 'group' ? $conf['allowed'] : $conf['foreign_table'];
+               $prependName = $conf['type'] == 'group' ? $conf['prepend_tname'] : '';
                $mmTable = isset($conf['MM']) && $conf['MM'] ? $conf['MM'] : '';
                $localizeForeignTable = isset($conf['foreign_table']) && BackendUtility::isTableLocalizable($conf['foreign_table']);
                $localizeReferences = $localizeForeignTable && isset($conf['localizeReferencesAtParentLocalization']) && $conf['localizeReferencesAtParentLocalization'];
@@ -5166,7 +5163,7 @@ class DataHandler {
                                }
                        }
                } elseif ($this->isReferenceField($conf)) {
-                       $allowedTables = $conf['type'] == 'group' ? $conf['allowed'] : $conf['foreign_table'] . ',' . $conf['neg_foreign_table'];
+                       $allowedTables = $conf['type'] == 'group' ? $conf['allowed'] : $conf['foreign_table'];
                        $dbAnalysis = $this->createRelationHandlerInstance();
                        $dbAnalysis->start($value, $allowedTables, $conf['MM'], $uid, $table, $conf);
                        foreach ($dbAnalysis->itemArray as $v) {
@@ -5339,8 +5336,8 @@ class DataHandler {
                foreach ($GLOBALS['TCA'][$table]['columns'] as $field => $fConf) {
                        $conf = $fConf['config'];
                        if ($this->isReferenceField($conf)) {
-                               $allowedTables = $conf['type'] == 'group' ? $conf['allowed'] : $conf['foreign_table'] . ',' . $conf['neg_foreign_table'];
-                               $prependName = $conf['type'] == 'group' ? $conf['prepend_tname'] : $conf['neg_foreign_table'];
+                               $allowedTables = $conf['type'] == 'group' ? $conf['allowed'] : $conf['foreign_table'];
+                               $prependName = $conf['type'] == 'group' ? $conf['prepend_tname'] : '';
                                if ($conf['MM']) {
                                        /** @var $dbAnalysis RelationHandler */
                                        $dbAnalysis = $this->createRelationHandlerInstance();
@@ -5390,8 +5387,8 @@ class DataHandler {
                // Extract parameters:
                list($table, $uid, $field) = $pParams;
                if ($this->isReferenceField($dsConf)) {
-                       $allowedTables = $dsConf['type'] == 'group' ? $dsConf['allowed'] : $dsConf['foreign_table'] . ',' . $dsConf['neg_foreign_table'];
-                       $prependName = $dsConf['type'] == 'group' ? $dsConf['prepend_tname'] : $dsConf['neg_foreign_table'];
+                       $allowedTables = $dsConf['type'] == 'group' ? $dsConf['allowed'] : $dsConf['foreign_table'];
+                       $prependName = $dsConf['type'] == 'group' ? $dsConf['prepend_tname'] : '';
                        if ($dsConf['MM']) {
                                /** @var $dbAnalysis RelationHandler */
                                $dbAnalysis = $this->createRelationHandlerInstance();
@@ -5550,7 +5547,7 @@ class DataHandler {
                // Will be set TRUE if an upgrade should be done...
                $set = FALSE;
                // Allowed tables for references.
-               $allowedTables = $conf['type'] == 'group' ? $conf['allowed'] : $conf['foreign_table'] . ',' . $conf['neg_foreign_table'];
+               $allowedTables = $conf['type'] == 'group' ? $conf['allowed'] : $conf['foreign_table'];
                // Table name to prepend the UID
                $prependName = $conf['type'] == 'group' ? $conf['prepend_tname'] : '';
                // Which tables that should possibly not be remapped
@@ -5595,11 +5592,7 @@ class DataHandler {
                        if ($conf['MM']) {
                                $dbAnalysis->writeMM($conf['MM'], $MM_localUid, $prependName);
                        } else {
-                               $vArray = $dbAnalysis->getValueArray($prependName);
-                               if ($conf['type'] == 'select') {
-                                       $vArray = $dbAnalysis->convertPosNeg($vArray, $conf['foreign_table'], $conf['neg_foreign_table']);
-                               }
-                               return $vArray;
+                               return $dbAnalysis->getValueArray($prependName);
                        }
                }
                return NULL;
index 21eb127..21c8f19 100644 (file)
@@ -758,7 +758,7 @@ class ReferenceIndex {
                        return $dbAnalysis->itemArray;
                        // DB record lists:
                } elseif ($this->isDbReferenceField($conf)) {
-                       $allowedTables = $conf['type'] === 'group' ? $conf['allowed'] : $conf['foreign_table'] . ',' . $conf['neg_foreign_table'];
+                       $allowedTables = $conf['type'] === 'group' ? $conf['allowed'] : $conf['foreign_table'];
                        if ($conf['MM_opposite_field']) {
                                return array();
                        }
index c5a0a7b..8951d50 100644 (file)
@@ -959,8 +959,10 @@ class RelationHandler {
         * @param string $fTable Foreign table (the one used for positive numbers)
         * @param string $nfTable Negative foreign table
         * @return array The array with ID integer values, converted to positive for those where the table name was set but did NOT match the positive foreign table.
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
         */
        public function convertPosNeg($valueArray, $fTable, $nfTable) {
+               GeneralUtility::logDeprecatedFunction();
                if (is_array($valueArray) && $fTable) {
                        foreach ($valueArray as $key => $val) {
                                $val = strrev($val);
index c267c1a..f46231d 100644 (file)
@@ -1,5 +1,7 @@
+========================================================================================================================
 Breaking: #24186 - HTMLparser - fixAttrib.['class'].list does not assign first element, when attribute value not in list
-=========================================================================================================================
+========================================================================================================================
+
 
 Description
 ===========
@@ -7,11 +9,13 @@ Description
 The HTMLparser now assigns the first class of ``fixAttrib.class.list`` when none of the given class name values
 are found in the configured list. Until now the class attribute of the rendered HTMl tag was just empty in that case.
 
+
 Impact
 ======
 
 A HTMl element that had no class before could now have been assigned a class.
 
+
 Migration
 =========
 
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-69028-DropNegForeignTable.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-69028-DropNegForeignTable.rst
new file mode 100644 (file)
index 0000000..cbeb99f
--- /dev/null
@@ -0,0 +1,44 @@
+===========================================================
+Breaking: #69028 - TCA type select - Drop neg_foreign_table
+===========================================================
+
+
+Description
+===========
+
+The following ``TCA`` keys for ``type`` ``select`` have been dropped and are no longer handled by the core:
+
+ * neg_foreign_table
+ * neg_foreign_table_where
+ * neg_foreign_table_prefix
+ * neg_foreign_table_loadIcons
+ * neg_foreign_table_imposeValueField
+
+These setting were used in ``select`` for comma separated value relations in addition to ``foreign_table``
+to allow a second connected table. Relations for ``neg_foreign_table`` were stored as negative uids in the
+field to distinguish them from relations to the table defined in ``foreign_table``.
+
+The functionality has been dropped without substitution and is no longer handled by the TYPO3 core.
+
+
+Impact
+======
+
+Existing relations to the table defined in ``neg_foreign_table`` will be discarded when a record
+with such a ``TCA`` configuration is saved to the database. The display of existing connected
+records may be misleading.
+
+
+Affected Installations
+======================
+
+This old school feature was never documented well and used by a very small amount of extensions.
+Searching an instance for the keyword ``neg_foreign_table`` will reveal usages.
+
+
+Migration
+=========
+
+In case records from multiple different tables must still be supported, the ``TCA`` configuration
+should be adapted to use a ``MM`` intermediate table. For existing migrations a database migration
+is required.
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-69028-RelationHandlerConvertPosNeg.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-69028-RelationHandlerConvertPosNeg.rst
new file mode 100644 (file)
index 0000000..78337d2
--- /dev/null
@@ -0,0 +1,30 @@
+=====================================================
+Deprecation: #69028 - RelationHandler convertPosNeg()
+=====================================================
+
+
+Description
+===========
+
+Method ``convertPosNeg()`` of class ``TYPO3\CMS\Core\Database\RelationHandler`` has been deprecated.
+
+
+Impact
+======
+
+The method should not be used any longer and will be removed with TYPO3 CMS 8.
+
+
+Affected Installations
+======================
+
+The method is rather internal and relatively unlikely to be used by third party modules.
+Searching for the string ``convertPosNeg`` may reveal possible usages.
+
+
+Migration
+=========
+
+The method was used together with the dropped ``neg_foreign_table`` handling for ``TCA`` ``select``
+fields. If this functionality is still needed, the method could be copied over to the third party
+application that uses it.
\ No newline at end of file