bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //COMMON \-> bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); //COMMON \-> bz2m_migration_profiles2mantis_user_table_callback( $row_count, $flag_first, $key, $value ); //CUSTOM bz2m_migration_products2mantis_project_table(); //CUSTOM \-> bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //COMMON \-> bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); //COMMON \-> bz2m_migration_products2mantis_project_table_callback( $row_count, $flag_first, $key, $value ); bz2m_migration_bugs2mantis_bug_table(); //CUSTOM \-> bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //COMMON \-> bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); //COMMON \-> bz2m_migration_bugs2mantis_bug_table_callback( $row_count, $flag_first, $key, $value ); bz2m_migration_bugs2mantis_bug_text_table(); //CUSTOM \-> bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //COMMON \-> bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); //COMMON \-> bz2m_migration_products2mantis_project_table_callback( $row_count, $flag_first, $key, $value ); //CUSTOM bz2m_migration_bugs_activity2mantis_bug_history_table(); //CUSTOM \-> bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //COMMON \-> bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); //COMMON \-> bz2m_migration_bugs_activity2mantis_bug_history_table_callback( $row_count, $flag_first, $key, $value ); //CUSTOM bz2m_migration_longdescs2mantis_bugnote_table(); //CUSTOM \-> bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //COMMON \-> bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); //COMMON \-> bz2m_migration_longdescs2mantis_bugnote_table_callback( $row_count, $flag_first, $key, $value ); //CUSTOM bz2m_migration_longdescs2mantis_bugnote_text_table(); //CUSTOM \-> bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //COMMON \-> bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); //COMMON \-> bz2m_migration_longdescs2mantis_bugnote_text_table_callback( $row_count, $flag_first, $key, $value ); //CUSTOM mysql_close( $link); */ // ------------------------------------------------------------------------------------------ // PHP CODE // ------------------------------------------------------------------------------------------ function bz2m_connect( &$link ) { // BUGZILLA - connect to database $link = mysql_connect('localhost', 'bugzilla3', 'pasteyourpasshere'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db("bugzilla3", $link); } // ------------------------------------------------------------------------------------------ function bz2m_select( $sql_fields, $sql_table, &$data, &$total ) { // BUGZILLA - read bugs $sql="SELECT "; $flag_first = true; foreach ($sql_fields as $key1=> $value1 ) { if($flag_first ) { $flag_first = false; $sql = $sql."`".$value1."`"; } else { $sql = $sql.","."`".$value1."`"; } } $sql = $sql." FROM "."`".$sql_table."`"; // $sql = $sql." FROM "."`".$sql_table."` WHERE `bug_id`<3"; // $sql = $sql." FROM "."`".$sql_table."` limit 0 ,3;"; //echo "
"; echo $sql; echo "
"; $result = mysql_query( $sql ); $columns = array(); $data = array(); // Table(Rows) while($row = mysql_fetch_array($result)) { foreach ($sql_fields as $key1=> $value1 ) { $columns[]= $row[$value1]; //echo "$value1 $row[$value1]
"; } $data[]= $columns; unset($columns); } $total = mysql_num_rows($result); mysql_free_result($result); } // ------------------------------------------------------------------------------------------ function bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, &$data, $callback_function ) { // MANTIS - write bugs $sql="INSERT INTO `$sql_table` ("; $flag_first = true; foreach ($sql_fields as $key1=> $value1 ) { if($flag_first ) { $flag_first = false; $sql = $sql."`".$value1."`"; } else { $sql = $sql.","."`".$value1."`"; } } $sql = $sql.") VALUES( "; $sql_header = $sql; foreach ($data as $key0 => $value0 ) { unset($sql); $sql = $sql_header; $row_count = $key0 + 1; $flag_first = true; foreach ($value0 as $key1 => $value1 ) { $sql.= call_user_func( $callback_function, $row_count, $flag_first, $sql_fields_source[$key1], $value1); if($flag_first ) $flag_first = false; //echo "
"; echo "$key1 $value1"; echo "
"; } $sql.= " );"; echo $sql; echo "
"; } } // ------------------------------------------------------------------------------------------ function bz2m_migration_profiles2mantis_user_table() //USERS { /* USERS ##### mysql> describe profiles; +----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | userid | mediumint(9) | NO | PRI | NULL | auto_increment | | login_name | varchar(255) | NO | UNI | NULL | | | cryptpassword | varchar(128) | YES | | NULL | | | realname | varchar(255) | YES | | NULL | | | disabledtext | mediumtext | NO | | NULL | | | mybugslink | tinyint(4) | NO | | 1 | | | refreshed_when | datetime | NO | | NULL | | | extern_id | varchar(64) | YES | | NULL | | +----------------+--------------+------+-----+---------+----------------+ 8 rows in set (0.00 sec) ##### mysql> describe mantis_user_table; +-----------------------------+------------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------------------+------------------+------+-----+---------------------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | username | varchar(32) | NO | UNI | NULL | | | realname | varchar(64) | NO | | NULL | | | email | varchar(64) | NO | | NULL | | | password | varchar(32) | NO | | NULL | | | date_created | datetime | NO | | 1970-01-01 00:00:01 | | | last_visit | datetime | NO | | 1970-01-01 00:00:01 | | | enabled | tinyint(4) | NO | MUL | 1 | | | protected | tinyint(4) | NO | | 0 | | | access_level | smallint(6) | NO | MUL | 10 | | | login_count | int(11) | NO | | 0 | | | lost_password_request_count | smallint(6) | NO | | 0 | | | failed_login_count | smallint(6) | NO | | 0 | | | cookie_string | varchar(64) | NO | UNI | NULL | | +-----------------------------+------------------+------+-----+---------------------+----------------+ 14 rows in set (0.00 sec) */ $sql_table_source= "profiles"; $sql_fields_source=array( "userid","login_name","cryptpassword","realname","login_name", "refreshed_when", "cryptpassword" ); $sql_table= "mantis_user_table"; $sql_fields = array("id","username","password","realname","email","date_created", "cookie_string"); $callback_function = "bz2m_migration_profiles2mantis_user_table_callback"; // ------ $data = array(); $total = 0; bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //echo "
"; echo "total:$total"; echo "
"; bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); } // ------------------------------------------------------------------------------------------ function bz2m_migration_profiles2mantis_user_table_callback( $row_count, $flag_first, $key, $value ) { // MANTIS - write bugs $sql = ""; //echo "$key $value
"; switch ($key) { case "userid": $value1 = $value; break; case "login_name": case "cryptpassword": case "realname": case "refreshed_when": $value1 = "'".str_replace("'", "''", $value)."'"; break; default: $value1 = "DEFAULT_".$key."=".$value."_DEFAULT"; break; } if( isset($value1) ) { if($flag_first ) { $sql = $value1; } else { $sql = ",".$value1; } } //echo "
"; echo $sql; return $sql; } // ------------------------------------------------------------------------------------------ function bz2m_migration_products2mantis_project_table() //PROJECTS { /* PROJECTS ##### mysql> describe products; +-------------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------------+-------------+------+-----+---------+----------------+ | id | smallint(6) | NO | PRI | NULL | auto_increment | | name | varchar(64) | NO | UNI | NULL | | | classification_id | smallint(6) | NO | | 1 | | | description | mediumtext | YES | | NULL | | | milestoneurl | tinytext | NO | | NULL | | | disallownew | tinyint(4) | NO | | NULL | | | votesperuser | smallint(6) | NO | | NULL | | | maxvotesperbug | smallint(6) | NO | | 10000 | | | votestoconfirm | smallint(6) | NO | | NULL | | | defaultmilestone | varchar(20) | NO | | --- | | +-------------------+-------------+------+-----+---------+----------------+ 10 rows in set (0.00 sec) mysql> ##### mysql> describe mantis_project_table; +-------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | name | varchar(128) | NO | UNI | NULL | | | status | smallint(6) | NO | | 10 | | | enabled | tinyint(4) | NO | | 1 | | | view_state | smallint(6) | NO | MUL | 10 | | | access_min | smallint(6) | NO | | 10 | | | file_path | varchar(250) | NO | | NULL | | | description | text | NO | | NULL | | +-------------+------------------+------+-----+---------+----------------+ 8 rows in set (0.01 sec) */ $sql_table_source= "products"; $sql_fields_source= array( "id","name","description","votesperuser","votestoconfirm" ); $sql_table= "mantis_project_table"; $callback_function = "bz2m_migration_products2mantis_project_table_callback"; $sql_fields = array("id","name","description", "status", "enabled"); // ---- $data = array(); $total = 0; bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //echo "
"; echo "total:$total"; echo "
"; bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); } // ------------------------------------------------------------------------------------------ function bz2m_migration_products2mantis_project_table_callback( $row_count, $flag_first, $key, $value ) { // MANTIS - write bugs $sql = ""; //echo "$key $value
"; switch ($key) { case "id": $value1 = $value; break; case "name": case "description": $value1 = "'".str_replace("'", "''", $value)."'"; break; case "votesperuser": $value1 = 10; break; case "votestoconfirm": $value1 = 1; break; default: $value1 = "DEFAULT_".$key."=".$value."_DEFAULT"; break; } if( isset($value1) ) { if($flag_first ) { $sql = $value1; } else { $sql = ",".$value1; } } //echo "
"; echo $sql; return $sql; } // ------------------------------------------------------------------------------------------ function bz2m_migration_bugs2mantis_bug_table() //BUGS { /* BUGS ##### mysql> describe bugs; +---------------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------------+--------------+------+-----+---------+----------------+ | bug_id | mediumint(9) | NO | PRI | NULL | auto_increment | | assigned_to | mediumint(9) | NO | MUL | NULL | | | bug_file_loc | text | YES | | NULL | | | bug_severity | varchar(64) | NO | MUL | NULL | | | bug_status | varchar(64) | NO | MUL | NULL | | | creation_ts | datetime | YES | MUL | NULL | | | delta_ts | datetime | NO | MUL | NULL | | | short_desc | mediumtext | NO | MUL | NULL | | | op_sys | varchar(64) | NO | MUL | NULL | | | priority | varchar(64) | NO | MUL | NULL | | | product_id | smallint(6) | NO | MUL | NULL | | | rep_platform | varchar(64) | NO | | NULL | | | reporter | mediumint(9) | NO | MUL | NULL | | | version | varchar(64) | NO | MUL | NULL | | | component_id | smallint(6) | NO | MUL | NULL | | | resolution | varchar(64) | NO | MUL | NULL | | | target_milestone | varchar(20) | NO | MUL | --- | | | qa_contact | mediumint(9) | YES | MUL | NULL | | | status_whiteboard | mediumtext | NO | | NULL | | | votes | mediumint(9) | NO | MUL | 0 | | | keywords | mediumtext | NO | | NULL | | | lastdiffed | datetime | YES | | NULL | | | everconfirmed | tinyint(4) | NO | | NULL | | | reporter_accessible | tinyint(4) | NO | | 1 | | | cclist_accessible | tinyint(4) | NO | | 1 | | | estimated_time | decimal(5,2) | NO | | 0.00 | | | remaining_time | decimal(5,2) | NO | | 0.00 | | | deadline | datetime | YES | | NULL | | | alias | varchar(20) | YES | UNI | NULL | | +---------------------+--------------+------+-----+---------+----------------+ 29 rows in set (0.00 sec) ##### mysql> describe mantis_bug_table; +-------------------+------------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------------+------------------+------+-----+---------------------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | project_id | int(10) unsigned | NO | MUL | 0 | | | reporter_id | int(10) unsigned | NO | | 0 | | | handler_id | int(10) unsigned | NO | | 0 | | | duplicate_id | int(10) unsigned | NO | | 0 | | | priority | smallint(6) | NO | | 30 | | | severity | smallint(6) | NO | | 50 | | | reproducibility | smallint(6) | NO | | 10 | | | status | smallint(6) | NO | MUL | 10 | | | resolution | smallint(6) | NO | | 10 | | | projection | smallint(6) | NO | | 10 | | | category | varchar(64) | NO | | NULL | | | date_submitted | int | NO | | NULL | | | last_updated | int | NO | | NULL | | | eta | smallint(6) | NO | | 10 | | | bug_text_id | int(10) unsigned | NO | | 0 | | | os | varchar(32) | NO | | NULL | | | os_build | varchar(32) | NO | | NULL | | | platform | varchar(32) | NO | | NULL | | | version | varchar(64) | NO | | NULL | | | fixed_in_version | varchar(64) | NO | MUL | NULL | | | build | varchar(32) | NO | | NULL | | | profile_id | int(10) unsigned | NO | | 0 | | | view_state | smallint(6) | NO | | 10 | | | summary | varchar(128) | NO | | NULL | | | sponsorship_total | int(11) | NO | MUL | 0 | | | sticky | tinyint(4) | NO | | 0 | | +-------------------+------------------+------+-----+---------------------+----------------+ 27 rows in set (0.00 sec) mysql> */ $sql_table_source= "bugs"; $sql_fields_source = array( "bug_id","assigned_to","bug_severity","bug_status","product_id","creation_ts","creation_ts","priority","reporter", "short_desc", "bug_id" ); $sql_table= "mantis_bug_table"; $callback_function = "bz2m_migration_bugs2mantis_bug_table_callback"; $sql_fields = array("id","handler_id","severity","status","project_id","date_submitted","last_updated","priority","reporter_id", "summary", "bug_text_id" ); // --- $data = array(); $total = 0; bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //echo "
"; echo "total:$total"; echo "
"; bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); } // ------------------------------------------------------------------------------------------ function bz2m_migration_bugs2mantis_bug_table_callback( $row_count, $flag_first, $key, $value ) { // MANTIS - write bugs $sql = ""; $bug_severity_map = array( "enhancement"=>10, "trivial"=>20, "Standby"=>20, "minor"=>40, "Low"=>40, "normal"=>50, "Normal"=>50, "major"=>60, "High"=>60, "critical"=>70, "Urgent"=>70, "blocker"=>80 ); $bug_status_map = array( "UNCONFIRMED"=>10, "NEW"=>40, "ASSIGNED"=>50, "RESOLVED"=>80, "CLOSED"=>90, "NON CONFIRMÉ"=>10, "RÉOUVERT"=>40, "REOPEN"=>40, "NOUVEAU"=>40, "ASSIGNÉ"=>50, "VÉRIFIÉ"=>50, "RESOLU"=>80, "FERMÉ"=>90 ); $priority_map = array( "Standby"=>10, "Low"=>20, "Normal"=>30, "High"=>40 ); //echo "$key $value
"; switch ($key) { case "bug_id": case "assigned_to": case "reporter": case "product_id": $value1 = $value; break; case "short_desc": $value = str_replace("\"","'",$value ); $value1 = "\"".$value."\""; break; case "creation_ts": $value1 = strtotime( $value ); break; case "bug_severity": if( isset($bug_severity_map[$value]) ) { $value1 = $bug_severity_map[$value]; } else { $value1 = "VALUE_ERROR_".$value."_VALUE_ERROR"; } break; case "bug_status": if( isset($bug_status_map[$value]) ) { $value1 = $bug_status_map[$value]; } else { $value1 = "VALUE_ERROR_".$value."_VALUE_ERROR"; } break; case "priority": if( isset($priority_map[$value]) ) { $value1 = $priority_map[$value]; } else { $value1 = "VALUE_ERROR_".$value."_VALUE_ERROR"; } break; default: $value1 = "DEFAULT_".$key."=".$value."_DEFAULT"; break; } if( isset($value1) ) { if($flag_first ) { $sql = $value1; } else { $sql = ",".$value1; } } //echo "
"; echo $sql; return $sql; } // ------------------------------------------------------------------------------------------ function bz2m_migration_bugs_activity2mantis_bug_history_table() //BUGS HISTORY { /* BUGS HISTORY ##### mysql> describe bugs_activity; +-----------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+---------+-------+ | bug_id | mediumint(9) | NO | MUL | NULL | | | attach_id | mediumint(9) | YES | | NULL | | | who | mediumint(9) | NO | MUL | NULL | | | bug_when | datetime | NO | MUL | NULL | | | fieldid | mediumint(9) | NO | MUL | NULL | | | added | tinytext | YES | | NULL | | | removed | tinytext | YES | | NULL | | +-----------+--------------+------+-----+---------+-------+ 7 rows in set (0.00 sec) ##### mysql> describe mantis_bug_history_table; +---------------+------------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+------------------+------+-----+---------------------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | user_id | int(10) unsigned | NO | MUL | 0 | | | bug_id | int(10) unsigned | NO | MUL | 0 | | | date_modified | int | NO | | NULL | | | field_name | varchar(32) | NO | | NULL | | | old_value | varchar(128) | NO | | NULL | | | new_value | varchar(128) | NO | | NULL | | | type | smallint(6) | NO | | 0 | | +---------------+------------------+------+-----+---------------------+----------------+ 8 rows in set (0.00 sec) */ $sql_table_source= "bugs_activity"; $sql_fields_source = array( "bug_id","who","bug_when","fieldid","added","removed" ); $sql_table= "mantis_bug_history_table"; $callback_function = "bz2m_migration_bugs_activity2mantis_bug_history_table_callback"; $sql_fields = array("bug_id","user_id","date_modified","field_name","old_value","new_value"); // ---- $data = array(); $total = 0; bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //echo "
"; echo "total:$total"; echo "
"; bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); } // ------------------------------------------------------------------------------------------ function bz2m_migration_bugs_activity2mantis_bug_history_table_callback( $row_count, $flag_first, $key, $value ) { // MANTIS - write bugs $sql = ""; //echo "$key $value
"; switch ($key) { case "bug_id": case "who": $value1 = $value; break; case "bug_when": $value1 = strtotime( $value ); break; case "fieldid": case "added": case "removed": $value1 = "'".str_replace("'", "''", $value)."'"; break; default: $value1 = "DEFAULT_".$key."=".$value."_DEFAULT"; break; } if( isset($value1) ) { if($flag_first ) { $sql = $value1; } else { $sql = ",".$value1; } } //echo "
"; echo $sql; return $sql; } // ------------------------------------------------------------------------------------------ function bz2m_migration_longdescs2mantis_bugnote_table() //BUGS DESCRIPTION { /* BUGS DESCRIPTION ##### | mysql> describe longdescs; +-----------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+--------------+------+-----+---------+-------+ | comment_id | mediumint(9) | NO | MUL | NULL | | | bug_id | mediumint(9) | NO | MUL | NULL | | | who | mediumint(9) | NO | MUL | NULL | | | bug_when | datetime | NO | MUL | NULL | | | work_time | decimal(5,2) | NO | | 0.00 | | | thetext | mediumtext | YES | MUL | NULL | | | isprivate | tinyint(4) | NO | | 0 | | | already_wrapped | tinyint(4) | NO | | 0 | | +-----------------+--------------+------+-----+---------+-------+ 7 rows in set (0.00 sec) ##### mysql> describe mantis_bugnote_table; +-----------------+------------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+------------------+------+-----+---------------------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | | | bug_id | int(10) unsigned | NO | MUL | 0 | | | reporter_id | int(10) unsigned | NO | | 0 | | | bugnote_text_id | int(10) unsigned | NO | | 0 | | | view_state | smallint(6) | NO | | 10 | | | date_submitted | int | NO | | NULL | | | last_modified | int | NO | MUL | NULL | | | note_type | int(11) | YES | | 0 | | | note_attr | varchar(250) | YES | | NULL | | +-----------------+------------------+------+-----+---------------------+----------------+ 9 rows in set (0.01 sec) mysql> ##### */ $sql_table_source= "longdescs"; $sql_fields_source = array("comment_id", "bug_id","who","bug_when","bug_when","work_time", ); $sql_table= "mantis_bugnote_table"; $callback_function = "bz2m_migration_longdescs2mantis_bugnote_table_callback"; $sql_fields = array("id", "bug_id","reporter_id","date_submitted","last_modified","bugnote_text_id",); // --------- $data = array(); $total = 0; bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //echo "
"; echo "total:$total"; echo "
"; bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); } // ------------------------------------------------------------------------------------------ function bz2m_migration_longdescs2mantis_bugnote_table_callback( $row_count, $flag_first, $key, $value ) { // MANTIS - write bugs $sql = ""; //echo "$key $value
"; switch ($key) { case "bug_id": case "who": case "comment_id": $value1 = $value; break; case "bug_when": $value1 = strtotime( $value ); break; case "work_time": $value1 = $row_count; break; case "thetext": $value = str_replace("\"","'",$value ); $value = str_replace("\\","\\\\",$value ); $value = str_replace("\n","
",$value ); $value1 = "\"".$value."\""; break; default: $value1 = "DEFAULT_".$key."=".$value."_DEFAULT"; break; } if( isset($value1) ) { if($flag_first ) { $sql = $value1; } else { $sql = ",".$value1; } } //echo "
"; echo $sql; return $sql; } // ------------------------------------------------------------------------------------------ function bz2m_migration_longdescs2mantis_bugnote_text_table() //BUGS DESCRIPTION { /* BUGS DESCRIPTION ##### | mysql> describe longdescs; +-----------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+--------------+------+-----+---------+-------+ | comment_id | mediumint(9) | NO | MUL | NULL | | | bug_id | mediumint(9) | NO | MUL | NULL | | | who | mediumint(9) | NO | MUL | NULL | | | bug_when | datetime | NO | MUL | NULL | | | work_time | decimal(5,2) | NO | | 0.00 | | | thetext | mediumtext | YES | MUL | NULL | | | isprivate | tinyint(4) | NO | | 0 | | | already_wrapped | tinyint(4) | NO | | 0 | | +-----------------+--------------+------+-----+---------+-------+ 7 rows in set (0.00 sec) mysql> describe mantis_bugnote_text_table; +-------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | | | note | text | NO | | NULL | | +-------+------------------+------+-----+---------+----------------+ 2 rows in set (0.00 sec) ##### */ $sql_table_source= "longdescs"; $sql_fields_source = array("comment_id", "thetext" ); $sql_table= "mantis_bugnote_text_table"; $callback_function = "bz2m_migration_longdescs2mantis_bugnote_text_table_callback"; $sql_fields = array("id", "note"); // --------- $data = array(); $total = 0; bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //echo "
"; echo "total:$total"; echo "
"; bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); } // ------------------------------------------------------------------------------------------ function bz2m_migration_longdescs2mantis_bugnote_text_table_callback( $row_count, $flag_first, $key, $value ) { // MANTIS - write bugs $sql = ""; //echo "$key $value
"; switch ($key) { case "bug_id": case "comment_id": $value1 = $value; break; case "thetext": $value = str_replace("\"","'",$value ); $value = str_replace("\\","\\\\",$value ); $value = str_replace("\n","
",$value ); $value1 = "\"".$value."\""; break; default: $value1 = "DEFAULT_".$key."=".$value."_DEFAULT"; break; } if( isset($value1) ) { if($flag_first ) { $sql = $value1; } else { $sql = ",".$value1; } } //echo "
"; echo $sql; return $sql; } // ------------------------------------------------------------------------------------------ function bz2m_migration_bugs2mantis_bug_text_table() //BUGS DESCRIPTION { /* BUGS DESCRIPTION ##### | mysql> describe bugs; +---------------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------------+--------------+------+-----+---------+----------------+ | bug_id | mediumint(9) | NO | PRI | NULL | auto_increment | | assigned_to | mediumint(9) | NO | MUL | NULL | | | bug_file_loc | text | YES | | NULL | | | bug_severity | varchar(64) | NO | MUL | NULL | | | bug_status | varchar(64) | NO | MUL | NULL | | | creation_ts | datetime | YES | MUL | NULL | | | delta_ts | datetime | NO | MUL | NULL | | | short_desc | mediumtext | NO | MUL | NULL | | | op_sys | varchar(64) | NO | MUL | NULL | | | priority | varchar(64) | NO | MUL | NULL | | | product_id | smallint(6) | NO | MUL | NULL | | | rep_platform | varchar(64) | NO | | NULL | | | reporter | mediumint(9) | NO | MUL | NULL | | | version | varchar(64) | NO | MUL | NULL | | | component_id | smallint(6) | NO | MUL | NULL | | | resolution | varchar(64) | NO | MUL | NULL | | | target_milestone | varchar(20) | NO | MUL | --- | | | qa_contact | mediumint(9) | YES | MUL | NULL | | | status_whiteboard | mediumtext | NO | | NULL | | | votes | mediumint(9) | NO | MUL | 0 | | | keywords | mediumtext | NO | | NULL | | | lastdiffed | datetime | YES | | NULL | | | everconfirmed | tinyint(4) | NO | | NULL | | | reporter_accessible | tinyint(4) | NO | | 1 | | | cclist_accessible | tinyint(4) | NO | | 1 | | | estimated_time | decimal(5,2) | NO | | 0.00 | | | remaining_time | decimal(5,2) | NO | | 0.00 | | | deadline | datetime | YES | | NULL | | | alias | varchar(20) | YES | UNI | NULL | | +---------------------+--------------+------+-----+---------+----------------+ 29 rows in set (0.00 sec) mysql> describe mantis_bug_text_table; +------------------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | description | text | NO | | NULL | | | steps_to_reproduce | text | NO | | NULL | | | additional_information | text | NO | | NULL | | +------------------------+------------------+------+-----+---------+----------------+ mysql> ##### */ $sql_table_source= "bugs"; $sql_fields_source = array( "bug_id","short_desc","resolution","alias"); $sql_table= "mantis_bug_text_table"; $callback_function = "bz2m_migration_bugs2mantis_bug_text_table_callback"; $sql_fields = array("id","description","additional_information","steps_to_reproduce"); // --- $data = array(); $total = 0; bz2m_select( $sql_fields_source, $sql_table_source, $data, $total ); //echo "
"; echo "total:$total"; echo "
"; bz2m_migration( $sql_fields_source, $sql_fields, $sql_table, $data, $callback_function ); } // ------------------------------------------------------------------------------------------ function bz2m_migration_bugs2mantis_bug_text_table_callback( $row_count, $flag_first, $key, $value ) { // MANTIS - write bugs $sql = ""; //echo "$key $value
"; switch ($key) { case "bug_id": $value1 = $value; break; case "short_desc": case "resolution": $value = str_replace("\"","'",$value ); $value = str_replace("\\","\\\\",$value ); $value = str_replace("\n","
",$value ); $value1 = "\"".$value."\""; break; case "alias": $value1 = "\"\""; break; default: $value1 = "DEFAULT_".$key."=".$value."_DEFAULT"; break; } if( isset($value1) ) { if($flag_first ) { $sql = $value1; } else { $sql = ",".$value1; } } //echo "
"; echo $sql; return $sql; } // ------------------------------------------------------------------------------------------ { // BUGZILLA - MAIN bz2m_connect($link); //echo "/* NB : FIRST CREATE ALL YOUR USER ACCOUNT IN MANTIS WITH THE CORRESPONDING ID FROM BUGZILLA */"; //echo "
"; //bz2m_migration_profiles2mantis_user_table(); //bz2m_migration_products2mantis_project_table(); //bz2m_migration_bugs2mantis_bug_table(); //bz2m_migration_bugs2mantis_bug_text_table(); //bz2m_migration_bugs_activity2mantis_bug_history_table(); bz2m_migration_longdescs2mantis_bugnote_table(); bz2m_migration_longdescs2mantis_bugnote_text_table(); mysql_close( $link); } ?>