PHORAX / formhandler

Fork of TYPO3 extension «Formhandler»
GNU General Public License v2.0
36 stars 54 forks source link

tt_address.hidden field prevents authcode generation? #57

Open TrueType opened 4 years ago

TrueType commented 4 years ago

working with a more current fork of this one (https://github.com/dmind-gmbh/formhandler) and the discontinued EXT:formhandler_subscription on TYPO3 v9:

Is that not needed in GenerateAuthCode.php, too?

TrueType commented 4 years ago
Index: Classes/Finisher/GenerateAuthCode.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- Classes/Finisher/GenerateAuthCode.php   (revision d1eb69adbe5cfa5fe31596bb3d475c68b7e9f32a)
+++ Classes/Finisher/GenerateAuthCode.php   (revision 68ed5aa563ea2f6a7945c4a1c2171348146bcf1b)
@@ -16,6 +16,7 @@

 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;

 /**
  * This finisher generates a unique code for a database entry.
@@ -60,13 +61,17 @@
         $uidField = $firstInsertInfo['uidField'] ?: 'uid';

         if ($table && $uid) {
-            $conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
-
-            $selectFields = '*';
-            if ($this->settings['selectFields']) {
-                $selectFields = $this->utilityFuncs->getSingle($this->settings, 'selectFields');
-            }
-            $row = $conn->select(explode(',', $selectFields), $table, [$uidField => $uid])->fetch();
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
+            $queryBuilder->getRestrictions()->removeByType(HiddenRestriction::class);
+            $row = $queryBuilder->select('*')
+                                ->from($table)
+                                ->where(
+                                    $queryBuilder->expr()->eq(
+                                        $uidField,
+                                        $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
+                                    )
+                                )
+                                ->execute()->fetch();
             if (!empty($row)) {
                 $authCode = $this->generateAuthCode($row);
                 $this->gp['generated_authCode'] = $authCode;