Commit 35bde18a authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[BUGFIX] EM: Use EXEC_TIME for extension export zip filename

Extension export as .zip file uses date() to make file
names "unique". Instead of timestamp "now", $GLOBALS['EXEC_TIME']
is now used as base time stamp since this value
does not change during one call.
The according test is stabilized a bit and additionally sets
$GLOBALS['EXEC_TIME'] to a stable value.

Releases: master
Resolves: #67405
Change-Id: I0ccb7210711fc7ab65135dc458d0b4a8587353d5
Reviewed-on: http://review.typo3.org/40159


Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Nicole Cordes's avatarNicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes's avatarNicole Cordes <typo3@cordes.co>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent e079c5d3
......@@ -374,7 +374,7 @@ class FileHandlingUtility implements \TYPO3\CMS\Core\SingletonInterface {
$version = '0.0.0';
}
$fileName = $this->getAbsolutePath('typo3temp/' . $extension . '_' . $version . '_' . date('YmdHi') . '.zip');
$fileName = $this->getAbsolutePath('typo3temp/' . $extension . '_' . $version . '_' . date('YmdHi', $GLOBALS['EXEC_TIME']) . '.zip');
$zip = new \ZipArchive();
$zip->open($fileName, \ZipArchive::CREATE);
......
......@@ -524,6 +524,9 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
* @test
*/
public function createZipFileFromExtensionGeneratesCorrectArchive() {
// 42 second of first day in 1970 - used to have achieve stable file names
$GLOBALS['EXEC_TIME'] = 42;
// Create extension for testing:
$extKey = $this->createFakeExtension();
$extensionRoot = $this->fakedExtensions[$extKey]['siteAbsPath'];
......@@ -551,12 +554,12 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
// Create zip-file from extension
$filename = $fileHandlerMock->_call('createZipFileFromExtension', $extKey);
$expectedFilename = PATH_site . 'typo3temp/' . $extKey . '_0.0.0_' . date('YmdHi') . '.zip';
$expectedFilename = PATH_site . 'typo3temp/' . $extKey . '_0.0.0_' . date('YmdHi', 42) . '.zip';
$this->testFilesToDelete[] = $filename;
$this->assertEquals($expectedFilename, $filename, 'Archive file name differs from expectation');
// File was created
$this->assertTrue(file_exists($filename), 'Zip file not created');
$this->testFilesToDelete[] = $filename;
// Read archive and check its contents
$archive = new \ZipArchive();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment