Skip to content

Commit

Permalink
Fix #11571: Versions 1.1 and 1.10 are treated as duplicates
Browse files Browse the repository at this point in the history
A problem was discovered on manage_proj_edit_page.php where if versions
1.1 and 1.10 were both shown, clicking 'edit' for 1.1 would bring up the
edit version page for the 1.10 version instead.

This is due to an incorrect version name comparison in version_get_id
whereby the following check between strings was occurring:

if( "1.1" == "1.10" ) { ... }

PHP evaluates this expression to true because 1.1 and 1.10 are treated
as floats. We however need to preserve the string type during this
comparison, thus we need to use the === comparison operator instead.
  • Loading branch information
davidhicks committed Mar 1, 2010
1 parent 76cd989 commit 3cca927
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/version_api.php
Expand Up @@ -490,7 +490,7 @@ function version_get_id( $p_version, $p_project_id = null, $p_inherit = null ) {
}

foreach( $g_cache_versions as $t_version ) {
if(( $t_version['version'] == $p_version ) && ( $t_version['project_id'] == $c_project_id ) ) {
if(( $t_version['version'] === $p_version ) && ( $t_version['project_id'] == $c_project_id ) ) {
return $t_version['id'];
}
}
Expand Down

0 comments on commit 3cca927

Please sign in to comment.