Skip to content

Commit

Permalink
Fix #9161, #9298: Upgrading from old database failed when projects ha…
Browse files Browse the repository at this point in the history
…d 2+ categories with same name but different case ('Cat' vs 'cat').
  • Loading branch information
amyreese committed Dec 9, 2008
1 parent 4b56ebe commit 366ff57
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions admin/install_functions.php
Expand Up @@ -56,10 +56,17 @@ function install_category_migrate() {

# In every project, go through all the categories found, and create them and update the bug
foreach( $t_data as $t_project_id => $t_categories ) {
$t_inserted = array();
foreach( $t_categories as $t_name => $t_true ) {
$query = "INSERT INTO $t_category_table ( name, project_id ) VALUES ( " . db_param() . ', ' . db_param() . ' )';
db_query_bound( $query, array( $t_name, $t_project_id ) );
$t_category_id = db_insert_id( $t_category_table );
$t_lower_name = mb_strtolower( $t_name );
if ( !isset( $t_inserted[$t_lower_name] ) ) {
$query = "INSERT INTO $t_category_table ( name, project_id ) VALUES ( " . db_param() . ', ' . db_param() . ' )';
db_query_bound( $query, array( $t_name, $t_project_id ) );
$t_category_id = db_insert_id( $t_category_table );
$t_inserted[$t_lower_name] = $t_category_id;
} else {
$t_category_id = $t_inserted[$t_lower_name];
}

$query = "UPDATE $t_bug_table SET category_id=" . db_param() . '
WHERE project_id=' . db_param() . ' AND category=' . db_param();
Expand Down

0 comments on commit 366ff57

Please sign in to comment.