Skip to content

Commit

Permalink
Update version checks
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Friedman <[email protected]>
  • Loading branch information
iMattPro committed Jun 12, 2024
1 parent c98c97b commit 055bd06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 7 additions & 12 deletions ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class ext extends \phpbb\extension\base
/** @var string Require 3.2.0 due to updated INCLUDECSS and ordered services */
const PHPBB_MIN_VERSION = '3.2.0';

/** @var string */
const PHPBB_MAX_VERSION = '4.0.0-dev';

/**
* Enable extension if phpBB minimum version requirement is met
* (check database and filesystem)
Expand All @@ -27,17 +30,9 @@ class ext extends \phpbb\extension\base
public function is_enableable()
{
$config = $this->container->get('config');
return $this->version_check($config['version']) && $this->version_check(PHPBB_VERSION);
}

/**
* Enable version check
*
* @param string|int $version The version to check
* @return bool
*/
protected function version_check($version)
{
return phpbb_version_compare($version, self::PHPBB_MIN_VERSION, '>=');
return phpbb_version_compare($config['version'], self::PHPBB_MIN_VERSION, '>=')
&& phpbb_version_compare($config['version'], self::PHPBB_MAX_VERSION, '<')
&& phpbb_version_compare(PHPBB_VERSION, self::PHPBB_MIN_VERSION, '>=')
&& phpbb_version_compare(PHPBB_VERSION, self::PHPBB_MAX_VERSION, '<');
}
}
2 changes: 2 additions & 0 deletions tests/system/ext_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public function ext_test_data()
array(ext::PHPBB_MIN_VERSION, true), // minimum version
array(PHPBB_VERSION, true), // current version
array('3.1.0', false), // old version
array(ext::PHPBB_MAX_VERSION, false), // max version
array('4.1.0', false), // way too new version
);
}

Expand Down

0 comments on commit 055bd06

Please sign in to comment.