diff options
author | redmatrix <git@macgirvin.com> | 2016-01-11 16:34:12 -0800 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-01-11 16:34:12 -0800 |
commit | 66c8658898b16f6a6468bddbbc6f882b3eaf3a7d (patch) | |
tree | ab823b8a9c4be9f4cf218ac08f7e2a52267b4f4c /include/plugin.php | |
parent | f4d47f825df40095f5b66b039dc6ca2d689e6b16 (diff) | |
download | volse-hubzilla-66c8658898b16f6a6468bddbbc6f882b3eaf3a7d.tar.gz volse-hubzilla-66c8658898b16f6a6468bddbbc6f882b3eaf3a7d.tar.bz2 volse-hubzilla-66c8658898b16f6a6468bddbbc6f882b3eaf3a7d.zip |
plugin version compatibility checking. To use, set MinVersion, MaxVersion or MinPHPversion in the plugin header block. Case is not important. We check the project versions against STD_VERSION, which should be rolled to a new y of x.x.y if the plugin interface or project code changes in an incompatible way.
Diffstat (limited to 'include/plugin.php')
-rwxr-xr-x | include/plugin.php | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/include/plugin.php b/include/plugin.php index 4da73dfd8..ccd88d963 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -348,19 +348,46 @@ function get_plugin_info($plugin){ } else { $info[$k][] = array('name' => $v); } - } else { -// if (array_key_exists($k, $info)){ - $info[$k] = $v; -// } + } + else { + $info[$k] = $v; } } } } - return $info; } +function check_plugin_versions($info) { + + if(! is_array($info)) + return true; + + if(array_key_exists('minversion',$info)) { + if(version_compare(trim($info['minversion']),STD_VERSION, '<')) { + logger('minversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING); + return false; + } + } + if(array_key_exists('maxversion',$info)) { + if(version_compare(trim($info['maxversion']),STD_VERSION, '>')) { + logger('maxversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING); + return false; + } + } + if(array_key_exists('minphpversion',$info)) { + if(version_compare(trim($info['minphpversion']),PHP_VERSION, '<')) { + logger('minphpversion limit: ' . $info['name'],LOGGER_NORMAL,LOG_WARNING); + return false; + } + } + + return true; +} + + + /** * @brief Parse theme comment in search of theme infos. |