[BUGFIX] Fix reference count when ref_table is sys_file 99/50299/3
authorWouter Wolters <typo3@wouterwolters.nl>
Fri, 21 Oct 2016 08:27:57 +0000 (10:27 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 21 Oct 2016 14:17:21 +0000 (16:17 +0200)
When ref_table is sys_file the references to sys_file_metadata
should be excluded. Otherwise the deletion of sys_file records
can throw a message that there still is a reference but that is
not listed in the filelist column "Ref".

Resolves: #78368
Releases: master,7.6,6.2
Change-Id: I8cbfd93f53e1c3bf78e1f5a23f84ccae731da3ff
Reviewed-on: https://review.typo3.org/50299
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Stephan GroƟberndt <stephan@grossberndt.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Robert van Kammen <rvkammen@hotmail.com>
Tested-by: Robert van Kammen <rvkammen@hotmail.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/backend/Classes/Utility/BackendUtility.php

index 035955a..0a20c1e 100644 (file)
@@ -4139,6 +4139,10 @@ class BackendUtility
                 );
             } else {
                 $queryBuilder->andWhere($queryBuilder->expr()->eq('ref_uid', (int)$ref));
+
+                if ($table === 'sys_file') {
+                    $queryBuilder->andWhere($queryBuilder->expr()->neq('tablename', $queryBuilder->quote('sys_file_metadata')));
+                }
             }
 
             $count = $queryBuilder->execute()->fetchColumn(0);