[BUGFIX] Use correct order of SQL parameters in SysRefindexHashUpdater 97/52397/4
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Sat, 8 Apr 2017 21:31:36 +0000 (14:31 -0700)
committerMarkus Klein <markus.klein@typo3.org>
Fri, 14 Apr 2017 07:59:24 +0000 (09:59 +0200)
Supply the positional parameter arguments to the update statement in
the correct order. The statement used for the updates reads
'UPDATE `sys_refindex` SET `hash` = ? WHERE `hash` = ?'
and thus the parameters should be in the order new hash, old hash,
not the other way around.
It's the final order in the statement that's relevant when supplying the
parameters, not the order in which they are defined in PHP.

Changed the definition order in PHP to match the order in the final
SQL statement as well.

Change-Id: I7829bbc835a6b0f263b61fa07b2e39b36d846275
Resolves: #80766
Releases: master
Reviewed-on: https://review.typo3.org/52397
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/install/Classes/Updates/SysRefindexHashUpdater.php

index dc59bca..a1930e3 100644 (file)
@@ -117,13 +117,13 @@ class SysRefindexHashUpdater extends AbstractUpdate
 
         $updateQueryBuilder = $connection->createQueryBuilder();
         $updateQueryBuilder->update('sys_refindex')
+            ->set('hash', $updateQueryBuilder->createPositionalParameter('', \PDO::PARAM_STR), false)
             ->where(
                 $updateQueryBuilder->expr()->eq(
                     'hash',
                     $updateQueryBuilder->createPositionalParameter('', \PDO::PARAM_STR)
                 )
-            )
-            ->set('hash', $updateQueryBuilder->createPositionalParameter('', \PDO::PARAM_STR), false);
+            );
         $databaseQueries[] = $updateQueryBuilder->getSQL();
         $updateStatement = $connection->prepare($updateQueryBuilder->getSQL());
 
@@ -131,7 +131,7 @@ class SysRefindexHashUpdater extends AbstractUpdate
         try {
             while ($row = $statement->fetch()) {
                 $newHash = md5(implode('///', array_diff_key($row, ['hash' => true])) . '///' . $this->hashVersion);
-                $updateStatement->execute([$row['hash'], $newHash]);
+                $updateStatement->execute([$newHash, $row['hash']]);
             }
             $connection->commit();
             $this->markWizardAsDone();