diff --git a/Classes/Service/Cleanup/Files.php b/Classes/Service/Cleanup/Files.php
index 9fd30c5..4dd7cc4 100644
--- a/Classes/Service/Cleanup/Files.php
+++ b/Classes/Service/Cleanup/Files.php
@@ -120,7 +120,15 @@ class Files
'reference',
'reference.uid_local = file.uid'
)
- ->where($queryBuilder->expr()->eq('reference.deleted', 1));
+ ->where($queryBuilder->expr()->eq(
+ 'reference.deleted',
+ 1
+ ))
+ ->andWhere($queryBuilder->expr()->like(
+ 'reference.tablenames',
+ $queryBuilder->createNamedParameter('tx_events_domain_model_%')
+ ))
+ ;
/** @var array{int: array{storage: int, identifier: string, uid: int}} $filesToDelete */
$filesToDelete = $queryBuilder->execute()->fetchAll();
diff --git a/Documentation/Changelog/3.0.0.rst b/Documentation/Changelog/3.0.0.rst
index 06000c9..1077aef 100644
--- a/Documentation/Changelog/3.0.0.rst
+++ b/Documentation/Changelog/3.0.0.rst
@@ -68,6 +68,10 @@ Fixes
Relates: #10175
+* Do not delete files which are unrelated to the events extension.
+
+ Relates: #10011
+
Tasks
-----
diff --git a/Tests/Functional/Cleanup/Fixtures/RemovePastTest.xml b/Tests/Functional/Cleanup/Fixtures/RemovePastTest.xml
index d89342a..561e86c 100644
--- a/Tests/Functional/Cleanup/Fixtures/RemovePastTest.xml
+++ b/Tests/Functional/Cleanup/Fixtures/RemovePastTest.xml
@@ -132,6 +132,26 @@
475768e491580fb8b74ed36c2b1aaf619ca5e11d
b4ab666a114d9905a50606d1837b74d952dfd90f
+
+ 4
+ 0
+ 1371467047
+ 2
+ 1
+ /user_uploads/example-to-keep.gif
+ gif
+ image/gif
+ example-to-keep.gif
+ 359ae0fb420fe8afe1a8b8bc5e46d75090a826b9
+ 637
+ 1370877201
+ 1369407629
+ 0
+ 0
+ 0
+ 475768e491580fb8b74ed36c2b1aaf619ca5e11d
+ b4ab666a114d9905a50606d1837b74d952dfd90f
+
1
@@ -157,6 +177,14 @@
1
3
+
+ 4
+ 0
+ 1371467047
+ 1371467047
+ 1
+ 4
+
1
@@ -206,6 +234,22 @@
1
sys_file
+
+ 4
+ 2
+ 1373537480
+ 1371484347
+ 1
+ 1
+ 0
+ 0
+ 4
+ 1
+ tt_content
+ images
+ 1
+ sys_file
+
1
diff --git a/Tests/Functional/Cleanup/Fixtures/RemovePastTestFileadmin/user_uploads/example-to-keep.gif b/Tests/Functional/Cleanup/Fixtures/RemovePastTestFileadmin/user_uploads/example-to-keep.gif
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/Functional/Cleanup/RemovePastTest.php b/Tests/Functional/Cleanup/RemovePastTest.php
index 582118a..5ac279e 100644
--- a/Tests/Functional/Cleanup/RemovePastTest.php
+++ b/Tests/Functional/Cleanup/RemovePastTest.php
@@ -76,25 +76,26 @@ class RemovePastTest extends FunctionalTestCase
);
self::assertCount(
- 2,
+ 3,
$this->getAllRecords('sys_file'),
'Unexpected number of sys_file records.'
);
self::assertCount(
- 2,
+ 3,
$this->getAllRecords('sys_file_reference'),
'Unexpected number of sys_file_reference records.'
);
self::assertCount(
- 2,
+ 3,
$this->getAllRecords('sys_file_metadata'),
'Unexpected number of sys_file_metadata records.'
);
$files = GeneralUtility::getFilesInDir('fileadmin/user_uploads');
self::assertIsArray($files, 'Failed to retrieve files from filesystem.');
- self::assertCount(2, $files, 'Unexpectd number of files in filesystem.');
+ self::assertCount(3, $files, 'Unexpected number of files in filesystem.');
self::assertSame('example-for-future-event.gif', array_values($files)[0], 'Unexpected file in filesystem.');
self::assertSame('example-for-partner.gif', array_values($files)[1], 'Unexpected file in filesystem.');
+ self::assertSame('example-to-keep.gif', array_values($files)[2], 'Unexpected file in filesystem.');
}
}