diff --git a/src/Composer/Compiler.php b/src/Composer/Compiler.php index b7979ef2b..971c2f29e 100644 --- a/src/Composer/Compiler.php +++ b/src/Composer/Compiler.php @@ -51,9 +51,8 @@ class Compiler throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from composer git repository clone and that git binary is available.'); } - $date = new \DateTime(trim($process->getOutput())); - $date->setTimezone(new \DateTimeZone('UTC')); - $this->versionDate = $date->format('Y-m-d H:i:s'); + $this->versionDate = new \DateTime(trim($process->getOutput())); + $this->versionDate->setTimezone(new \DateTimeZone('UTC')); $process = new Process('git describe --tags --exact-match HEAD'); if ($process->run() == 0) { @@ -74,7 +73,7 @@ class Compiler $phar->startBuffering(); $finderSort = function ($a, $b) { - return strcmp($a, $b); + return strcmp(strtr($a->getRealPath(), '\\', '/'), strtr($b->getRealPath(), '\\', '/')); }; $finder = new Finder(); @@ -160,7 +159,7 @@ class Compiler if ($path === 'src/Composer/Composer.php') { $content = str_replace('@package_version@', $this->version, $content); $content = str_replace('@package_branch_alias_version@', $this->branchAliasVersion, $content); - $content = str_replace('@release_date@', $this->versionDate, $content); + $content = str_replace('@release_date@', $this->versionDate->format('Y-m-d H:i:s'), $content); } $phar->addFromString($path, $content); @@ -236,9 +235,9 @@ Phar::mapPhar('composer.phar'); EOF; - // add warning once the phar is older than 30 days + // add warning once the phar is older than 60 days if (preg_match('{^[a-f0-9]+$}', $this->version)) { - $warningTime = time() + 30*86400; + $warningTime = $this->versionDate->format('U') + 60 * 86400; $stub .= "define('COMPOSER_DEV_WARNING_TIME', $warningTime);\n"; } diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index b2f9d5e7b..12bb08dc7 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -104,7 +104,7 @@ class Application extends BaseApplication } if ($commandName !== 'self-update' && $commandName !== 'selfupdate') { if (time() > COMPOSER_DEV_WARNING_TIME) { - $this->getIO()->writeError(sprintf('Warning: This development build of composer is over 30 days old. It is recommended to update it by running "%s self-update" to get the latest version.', $_SERVER['PHP_SELF'])); + $this->getIO()->writeError(sprintf('Warning: This development build of composer is over 60 days old. It is recommended to update it by running "%s self-update" to get the latest version.', $_SERVER['PHP_SELF'])); } } } diff --git a/tests/Composer/Test/ApplicationTest.php b/tests/Composer/Test/ApplicationTest.php index 0f1a076b4..58a02ef4f 100644 --- a/tests/Composer/Test/ApplicationTest.php +++ b/tests/Composer/Test/ApplicationTest.php @@ -30,7 +30,7 @@ class ApplicationTest extends TestCase $outputMock->expects($this->once()) ->method("write") - ->with($this->equalTo(sprintf('Warning: This development build of composer is over 30 days old. It is recommended to update it by running "%s self-update" to get the latest version.', $_SERVER['PHP_SELF']))); + ->with($this->equalTo(sprintf('Warning: This development build of composer is over 60 days old. It is recommended to update it by running "%s self-update" to get the latest version.', $_SERVER['PHP_SELF']))); if (!defined('COMPOSER_DEV_WARNING_TIME')) { define('COMPOSER_DEV_WARNING_TIME', time() - 1);