diff options
| author | Nils Adermann <naderman@naderman.de> | 2011-07-16 22:21:49 -0400 |
|---|---|---|
| committer | Nils Adermann <naderman@naderman.de> | 2011-07-16 22:21:49 -0400 |
| commit | 82fa4eff7ebcc10b808de9dacb7520ad0d2e1df1 (patch) | |
| tree | e107bdad4072b3dd8c747f1aab4ba6e2df1db5f7 /phpBB/includes | |
| parent | 825d44fcc2b384729a8eb0c941c5d3509f967e4c (diff) | |
| parent | 7f56c05f2450dbf33e48d2c1b9885353ddd58beb (diff) | |
| download | forums-82fa4eff7ebcc10b808de9dacb7520ad0d2e1df1.tar forums-82fa4eff7ebcc10b808de9dacb7520ad0d2e1df1.tar.gz forums-82fa4eff7ebcc10b808de9dacb7520ad0d2e1df1.tar.bz2 forums-82fa4eff7ebcc10b808de9dacb7520ad0d2e1df1.tar.xz forums-82fa4eff7ebcc10b808de9dacb7520ad0d2e1df1.zip | |
Merge remote-tracking branch 'github-bantu/ticket/10263' into develop-olympus
* github-bantu/ticket/10263:
[ticket/10263] Call phpbb_version_compare() from includes/acp/acp_main.php
[ticket/10263] Call phpbb_version_compare() from includes/acp/acp_update.php
[ticket/10263] Adding unit tests for phpbb_version_compare().
[ticket/10263] Add wrapper for version_compare() that allows the use of A and B
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/acp/acp_main.php | 5 | ||||
| -rw-r--r-- | phpBB/includes/acp/acp_update.php | 7 | ||||
| -rw-r--r-- | phpBB/includes/functions.php | 28 |
3 files changed, 31 insertions, 9 deletions
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 60cebe3c08..68445d814f 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -415,11 +415,8 @@ class acp_main { $latest_version_info = explode("\n", $latest_version_info); - $latest_version = str_replace('rc', 'RC', strtolower(trim($latest_version_info[0]))); - $current_version = str_replace('rc', 'RC', strtolower($config['version'])); - $template->assign_vars(array( - 'S_VERSION_UP_TO_DATE' => version_compare($current_version, $latest_version, '<') ? false : true, + 'S_VERSION_UP_TO_DATE' => phpbb_version_compare(trim($latest_version_info[0]), $config['version'], '<='), )); } diff --git a/phpBB/includes/acp/acp_update.php b/phpBB/includes/acp/acp_update.php index b0ce8f1084..931fa53165 100644 --- a/phpBB/includes/acp/acp_update.php +++ b/phpBB/includes/acp/acp_update.php @@ -69,12 +69,9 @@ class acp_update $current_version = (!empty($version_update_from)) ? $version_update_from : $config['version']; - $up_to_date_automatic = (version_compare(str_replace('rc', 'RC', strtolower($current_version)), str_replace('rc', 'RC', strtolower($latest_version)), '<')) ? false : true; - $up_to_date = (version_compare(str_replace('rc', 'RC', strtolower($config['version'])), str_replace('rc', 'RC', strtolower($latest_version)), '<')) ? false : true; - $template->assign_vars(array( - 'S_UP_TO_DATE' => $up_to_date, - 'S_UP_TO_DATE_AUTO' => $up_to_date_automatic, + 'S_UP_TO_DATE' => phpbb_version_compare($latest_version, $config['version'], '<='), + 'S_UP_TO_DATE_AUTO' => phpbb_version_compare($latest_version, $current_version, '<='), 'S_VERSION_CHECK' => true, 'U_ACTION' => $this->u_action, 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'), diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 86eab4666f..83e56caedc 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -620,6 +620,34 @@ function phpbb_email_hash($email) } /** +* Wrapper for version_compare() that allows using uppercase A and B +* for alpha and beta releases. +* +* See http://www.php.net/manual/en/function.version-compare.php +* +* @param string $version1 First version number +* @param string $version2 Second version number +* @param string $operator Comparison operator (optional) +* +* @return mixed Integer (-1, 0, 1) if comparison operator is specified. +* Boolean (true, false) otherwise. +*/ +function phpbb_version_compare($version1, $version2, $operator = null) +{ + $version1 = strtolower($version1); + $version2 = strtolower($version2); + + if (is_null($operator)) + { + return version_compare($version1, $version2); + } + else + { + return version_compare($version1, $version2, $operator); + } +} + +/** * Global function for chmodding directories and files for internal use * * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. |
