[BUGFIX] Fix FilePermissionUpdate SQL errors 08/24808/3
authorNicole Cordes <typo3@cordes.co>
Tue, 15 Oct 2013 15:07:22 +0000 (17:07 +0200)
committerErnesto Baschny <ernst@cron-it.de>
Tue, 15 Oct 2013 17:48:12 +0000 (19:48 +0200)
If you have a new installation or already used the database analyser to
delete unnecessary fields the filePermissionUpdate throws SQL errors
because the old fields aren't available anymore.

Resolves: #52856
Releases: 6.2
Change-Id: Id74c7263d7686a574d128856fd7538dc110ba3bb
Reviewed-on: https://review.typo3.org/24808
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/install/Classes/Updates/FilePermissionUpdate.php

index 5099f55..d5278b3 100644 (file)
@@ -61,24 +61,30 @@ class FilePermissionUpdate extends AbstractUpdate {
                        // Field might not be there, so we need an update run to add the field
                        return TRUE;
                }
-               // Fetch user records where the old permission field is not empty but the new one is
-               $notMigratedRowsCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
-                       'uid',
-                       'be_users',
-                       $this->getWhereClause()
-               );
-               if ($notMigratedRowsCount > 0) {
-                       $updateNeeded = TRUE;
-               } else {
-                       // Fetch group records where the old permission field is not empty but the new one is
+               $beUsersFieldInformation = $GLOBALS['TYPO3_DB']->admin_get_fields('be_users');
+               if (isset($beUsersFieldInformation['fileoper_perms'])) {
+                       // Fetch user records where the old permission field is not empty but the new one is
                        $notMigratedRowsCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
                                'uid',
-                               'be_groups',
+                               'be_users',
                                $this->getWhereClause()
                        );
                        if ($notMigratedRowsCount > 0) {
                                $updateNeeded = TRUE;
                        }
+               } else {
+                       $beGroupsFieldInformation = $GLOBALS['TYPO3_DB']->admin_get_fields('be_groups');
+                       if (isset($beGroupsFieldInformation['fileoper_perms'])) {
+                               // Fetch group records where the old permission field is not empty but the new one is
+                               $notMigratedRowsCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                                       'uid',
+                                       'be_groups',
+                                       $this->getWhereClause()
+                               );
+                               if ($notMigratedRowsCount > 0) {
+                                       $updateNeeded = TRUE;
+                               }
+                       }
                }
                return $updateNeeded;
        }