[BUGFIX] Fix reference count when ref_table is sys_file 19/50319/3
authorWouter Wolters <typo3@wouterwolters.nl>
Fri, 21 Oct 2016 14:41:16 +0000 (16:41 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Tue, 25 Oct 2016 09:07:00 +0000 (11:07 +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/50319
Reviewed-by: Stephan GroƟberndt <stephan@grossberndt.de>
Tested-by: TYPO3com <no-reply@typo3.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 0806f04..f18ea89 100644 (file)
@@ -4191,6 +4191,9 @@ class BackendUtility
                 }
             } else {
                 $condition = 'ref_uid=' . (int)$ref;
+                if ($table === 'sys_file') {
+                    $condition .= ' AND tablename != ' . $db->fullQuoteStr('sys_file_metadata', $table);
+                }
             }
             $count = $db->exec_SELECTcountRows('*', 'sys_refindex', 'ref_table=' . $db->fullQuoteStr($table, 'sys_refindex') . ' AND ' . $condition . ' AND deleted=0');
         }