mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-10 00:36:10 +01:00
Do not delete files unrelated to events
This commit is contained in:
parent
2d2b9ac993
commit
6412c31be5
5 changed files with 62 additions and 5 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -68,6 +68,10 @@ Fixes
|
|||
|
||||
Relates: #10175
|
||||
|
||||
* Do not delete files which are unrelated to the events extension.
|
||||
|
||||
Relates: #10011
|
||||
|
||||
Tasks
|
||||
-----
|
||||
|
||||
|
|
|
@ -132,6 +132,26 @@
|
|||
<identifier_hash>475768e491580fb8b74ed36c2b1aaf619ca5e11d</identifier_hash>
|
||||
<folder_hash>b4ab666a114d9905a50606d1837b74d952dfd90f</folder_hash>
|
||||
</sys_file>
|
||||
<sys_file>
|
||||
<uid>4</uid>
|
||||
<pid>0</pid>
|
||||
<tstamp>1371467047</tstamp>
|
||||
<type>2</type>
|
||||
<storage>1</storage>
|
||||
<identifier>/user_uploads/example-to-keep.gif</identifier>
|
||||
<extension>gif</extension>
|
||||
<mime_type>image/gif</mime_type>
|
||||
<name>example-to-keep.gif</name>
|
||||
<sha1>359ae0fb420fe8afe1a8b8bc5e46d75090a826b9</sha1>
|
||||
<size>637</size>
|
||||
<creation_date>1370877201</creation_date>
|
||||
<modification_date>1369407629</modification_date>
|
||||
<last_indexed>0</last_indexed>
|
||||
<missing>0</missing>
|
||||
<metadata>0</metadata>
|
||||
<identifier_hash>475768e491580fb8b74ed36c2b1aaf619ca5e11d</identifier_hash>
|
||||
<folder_hash>b4ab666a114d9905a50606d1837b74d952dfd90f</folder_hash>
|
||||
</sys_file>
|
||||
|
||||
<sys_file_metadata>
|
||||
<uid>1</uid>
|
||||
|
@ -157,6 +177,14 @@
|
|||
<cruser_id>1</cruser_id>
|
||||
<file>3</file>
|
||||
</sys_file_metadata>
|
||||
<sys_file_metadata>
|
||||
<uid>4</uid>
|
||||
<pid>0</pid>
|
||||
<tstamp>1371467047</tstamp>
|
||||
<crdate>1371467047</crdate>
|
||||
<cruser_id>1</cruser_id>
|
||||
<file>4</file>
|
||||
</sys_file_metadata>
|
||||
|
||||
<sys_file_reference>
|
||||
<uid>1</uid>
|
||||
|
@ -206,6 +234,22 @@
|
|||
<sorting_foreign>1</sorting_foreign>
|
||||
<table_local>sys_file</table_local>
|
||||
</sys_file_reference>
|
||||
<sys_file_reference>
|
||||
<uid>4</uid>
|
||||
<pid>2</pid>
|
||||
<tstamp>1373537480</tstamp>
|
||||
<crdate>1371484347</crdate>
|
||||
<cruser_id>1</cruser_id>
|
||||
<deleted>1</deleted>
|
||||
<hidden>0</hidden>
|
||||
<sys_language_uid>0</sys_language_uid>
|
||||
<uid_local>4</uid_local>
|
||||
<uid_foreign>1</uid_foreign>
|
||||
<tablenames>tt_content</tablenames>
|
||||
<fieldname>images</fieldname>
|
||||
<sorting_foreign>1</sorting_foreign>
|
||||
<table_local>sys_file</table_local>
|
||||
</sys_file_reference>
|
||||
|
||||
<tx_events_domain_model_region>
|
||||
<uid>1</uid>
|
||||
|
|
|
@ -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.');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue