diff --git a/application/VERSION b/application/VERSION index 47f3a662f..519b667a7 100644 --- a/application/VERSION +++ b/application/VERSION @@ -1,2 +1 @@ -GitCommitID: $Format:%H%d$ -GitCommitDate: $Format:%ci$ +$Format:%H%d %ci$ diff --git a/application/views/scripts/about/index.phtml b/application/views/scripts/about/index.phtml index 3c37a5e73..53f5a1842 100644 --- a/application/views/scripts/about/index.phtml +++ b/application/views/scripts/about/index.phtml @@ -8,7 +8,7 @@ 'gitCommitID' => $this->translate('Git commit ID: %s'), 'gitCommitDate' => $this->translate('Git commit date: %s') ) as $key => $label) { - if (null !== ($value = $version[$key])) { + if (array_key_exists($key, $version) && null !== ($value = $version[$key])) { $versionInfo[] = sprintf($label, htmlspecialchars($value)); } } diff --git a/library/Icinga/Version.php b/library/Icinga/Version.php index 130e75060..4e5b36945 100644 --- a/library/Icinga/Version.php +++ b/library/Icinga/Version.php @@ -15,91 +15,29 @@ class Version */ public static function get() { - $versionInfo = array( - 'appVersion' => null, - 'gitCommitID' => null, - 'gitCommitDate' => null - ); - - if (false !== ($appVersion = @file( - Icinga::app()->getApplicationDir() . DIRECTORY_SEPARATOR . 'VERSION', - FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES + if (false === ($appVersion = @file_get_contents( + Icinga::app()->getApplicationDir() . DIRECTORY_SEPARATOR . 'VERSION' ))) { - foreach ($appVersion as $av) { - $matches = array(); - if (false === ($res = preg_match( - '/(?\w+)(?:\s*\(.*?(?:(?<=[\(,])\s*tag\s*:\s*v(?P.+?)\s*(?=[\),]).*?)?\))?\s*(?P\S+)/ms', + $appVersion, + $matches + ))) { + throw new IcingaException('Failed at preg_match()'); + } + if ($res === 0) { + return false; } - return $versionInfo; + foreach ($matches as $key => $value) { + if (is_int($key) || $value === '') { + unset($matches[$key]); + } + } + return $matches; } }