cache version number parsed from changelog for 5min on tree level

This commit is contained in:
Ralf Becker 2015-11-05 14:18:17 +00:00
parent aa7666baac
commit b0de2d57a6

View File

@ -1167,10 +1167,13 @@ abstract class egw_framework
* @return string * @return string
*/ */
public static function api_version(&$changelog=null) public static function api_version(&$changelog=null)
{
$changelog = EGW_SERVER_ROOT.'/doc/rpm-build/debian.changes';
return egw_cache::getTree(__CLASS__, 'api_version', function() use ($changelog)
{ {
$version = preg_replace('/[^0-9.]/', '', $GLOBALS['egw_info']['server']['versions']['phpgwapi']); $version = preg_replace('/[^0-9.]/', '', $GLOBALS['egw_info']['server']['versions']['phpgwapi']);
// parse version from changelog // parse version from changelog
$changelog = EGW_SERVER_ROOT.'/doc/rpm-build/debian.changes';
$matches = null; $matches = null;
if (($f = fopen($changelog, 'r')) && preg_match('/egroupware-epl \(([0-9.]+)/', fread($f, 80), $matches) && if (($f = fopen($changelog, 'r')) && preg_match('/egroupware-epl \(([0-9.]+)/', fread($f, 80), $matches) &&
version_compare($version, $matches[1], '<')) version_compare($version, $matches[1], '<'))
@ -1179,6 +1182,7 @@ abstract class egw_framework
fclose($f); fclose($f);
} }
return $version; return $version;
}, array(), 300);
} }
/** /**