[BUGFIX] EM: Use EXEC_TIME for extension export zip filename 59/40159/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 10 Jun 2015 20:55:29 +0000 (22:55 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 10 Jun 2015 21:34:44 +0000 (23:34 +0200)
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 <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/extensionmanager/Classes/Utility/FileHandlingUtility.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/FileHandlingUtilityTest.php

index e61e2ec..9228365 100644 (file)
@@ -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);
index 4cbdc9d..f9ce030 100644 (file)
@@ -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();