Jordi Boggiano 7 лет назад
Родитель
Сommit
4dc81db069
1 измененных файлов с 12 добавлено и 11 удалено
  1. 12 11
      src/Composer/Package/Loader/ValidatingArrayLoader.php

+ 12 - 11
src/Composer/Package/Loader/ValidatingArrayLoader.php

@@ -92,6 +92,17 @@ class ValidatingArrayLoader implements LoaderInterface
         $this->validateUrl('homepage');
         $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
 
+        $releaseDate = null;
+        $this->validateString('time');
+        if (!empty($this->config['time'])) {
+            try {
+                $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
+            } catch (\Exception $e) {
+                $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
+                unset($this->config['time']);
+            }
+        }
+
         if (isset($this->config['license'])) {
             if (is_string($this->config['license'])) {
                 $this->validateRegex('license', '[A-Za-z0-9+. ()-]+');
@@ -121,7 +132,7 @@ class ValidatingArrayLoader implements LoaderInterface
                         'If the software is closed-source, you may use "proprietary" as license.',
                         json_encode($this->config['license'])
                     );
-                } else {
+                } else if (!$releaseDate || $releaseDate->format('Y-m-d H:i:s') >= '2018-01-20 00:00:00') { // only warn for deprecations for releases/branches that follow the introduction of deprecated licenses
                     foreach ($licenses as $license) {
                         $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
                         if ($spdxLicense && $spdxLicense[3]) {
@@ -147,16 +158,6 @@ class ValidatingArrayLoader implements LoaderInterface
             }
         }
 
-        $this->validateString('time');
-        if (!empty($this->config['time'])) {
-            try {
-                $date = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
-            } catch (\Exception $e) {
-                $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
-                unset($this->config['time']);
-            }
-        }
-
         if ($this->validateArray('authors') && !empty($this->config['authors'])) {
             foreach ($this->config['authors'] as $key => $author) {
                 if (!is_array($author)) {