소스 검색

Make sure only proper timestamps are used for the lock, refs #1390

Jordi Boggiano 12 년 전
부모
커밋
8af6581bdf
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      src/Composer/Package/Locker.php

+ 2 - 2
src/Composer/Package/Locker.php

@@ -291,8 +291,8 @@ class Locker
                 if (function_exists('proc_open') && 'git' === $package->getSourceType() && ($path = $this->installationManager->getInstallPath($package))) {
                     $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
                     $process = new ProcessExecutor();
-                    if (0 === $process->execute('git log -n1 --pretty=%ct '.escapeshellarg($sourceRef), $output, $path) && !empty($output)) {
-                        $datetime = new \DateTime('@'.$output, new \DateTimeZone('UTC'));
+                    if (0 === $process->execute('git log -n1 --pretty=%ct '.escapeshellarg($sourceRef), $output, $path) && preg_match('{^\s*\d+\s*$}', $output)) {
+                        $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
                         $spec['time'] = $datetime->format('Y-m-d H:i:s');
                     }
                 }