Jeremy D commited on 2011-11-06 14:17:05
Showing 1 changed files, with 30 additions and 25 deletions.
... | ... |
@@ -35,18 +35,14 @@ class tbg_converter |
35 | 35 |
protected $db_user = 'tb3'; |
36 | 36 |
protected $db_pass = ''; |
37 | 37 |
|
38 |
- protected $mbt_db_name = 'mantis'; |
|
39 |
- protected $mbt_db_table_prefix = 'mantis_'; |
|
40 |
- |
|
38 |
+ // The database prefixes (including the database). |
|
39 |
+ protected $tbg_db_prefix; |
|
41 | 40 |
protected $tbg_db_name = 'tbg'; |
42 | 41 |
protected $tbg_db_table_prefix = 'tbg3_'; |
43 | 42 |
|
44 | 43 |
// Scope (usually just 1) |
45 | 44 |
protected $tbg_scope = 1; |
46 | 45 |
|
47 |
- // The database prefixes (including the database). |
|
48 |
- protected $tbg_db_prefix; |
|
49 |
- |
|
50 | 46 |
// The start timer. |
51 | 47 |
protected $start_time = 0; |
52 | 48 |
|
... | ... |
@@ -136,7 +132,7 @@ class tbg_converter |
136 | 132 |
{ |
137 | 133 |
// No special regex? |
138 | 134 |
if (!isset($setting['cli_regex'])) |
139 |
- $setting['cli_regex'] = '~^--' . $key . '=([^--]+)~i'; |
|
135 |
+ $setting['cli_regex'] = '~--' . $key . '=([^\s]+)[\s+--]?~i'; |
|
140 | 136 |
|
141 | 137 |
foreach ($_SERVER['argv'] as $i => $arg) |
142 | 138 |
{ |
... | ... |
@@ -151,6 +147,9 @@ class tbg_converter |
151 | 147 |
if ($setting['required'] && empty($_POST[$key])) |
152 | 148 |
exit('The argument, ' . $key . ', is required to continue.'); |
153 | 149 |
} |
150 |
+ |
|
151 |
+ // validate the settings. |
|
152 |
+ $errors = $this->setSettings(); |
|
154 | 153 |
} |
155 | 154 |
|
156 | 155 |
/** |
... | ... |
@@ -221,7 +220,7 @@ class tbg_converter |
221 | 220 |
public function loadSettings() |
222 | 221 |
{ |
223 | 222 |
// Lets check our session. |
224 |
- if (session_id() == '') |
|
223 |
+ if (session_id() == '' && empty($this->is_cli)) |
|
225 | 224 |
session_start(); |
226 | 225 |
|
227 | 226 |
if (isset($_SESSION['tbg_converter'])) |
... | ... |
@@ -331,7 +330,8 @@ class tbg_converter |
331 | 330 |
} |
332 | 331 |
catch (PDOException $e) |
333 | 332 |
{ |
334 |
- exit('Connection failed' . $e->getMessage()); |
|
333 |
+ echo $this->db_dsn; |
|
334 |
+ exit('TBG Connection failed: ' . $e->getMessage() . "\n"); |
|
335 | 335 |
} |
336 | 336 |
|
337 | 337 |
// Set the prefixes. |
... | ... |
@@ -372,6 +372,8 @@ class tbg_converter |
372 | 372 |
*/ |
373 | 373 |
function updateStep($step) |
374 | 374 |
{ |
375 |
+ $step = str_replace('doStep', '', $step) + 1; |
|
376 |
+ |
|
375 | 377 |
$_GET['step'] = (int) $step; |
376 | 378 |
|
377 | 379 |
$this->step = (int) $step; |
... | ... |
@@ -417,7 +419,7 @@ class tbg_converter |
417 | 419 |
$this->updateSubStep($substep + $max_step_size); |
418 | 420 |
|
419 | 421 |
// Hold on, we had less results than we should have. |
420 |
- if ($max_step_size < $count) |
|
422 |
+ if ($max_step_size > $count) |
|
421 | 423 |
$this->updateStep($function); |
422 | 424 |
|
423 | 425 |
// CLI conversions can just continue. |
... | ... |
@@ -466,6 +468,8 @@ class mbt_to_tbg extends tbg_converter |
466 | 468 |
// Credits for this part of the converter. |
467 | 469 |
protected $credits = 'Mantis -> TBG converter © Joshua Dickerson & Jeremy Darwood'; |
468 | 470 |
|
471 |
+ protected $mbt_db_name = 'mantis'; |
|
472 |
+ protected $mbt_db_table_prefix = 'mantis_'; |
|
469 | 473 |
protected $mbt_db_prefix; |
470 | 474 |
|
471 | 475 |
// What steps shall we take. |
... | ... |
@@ -531,7 +535,7 @@ class mbt_to_tbg extends tbg_converter |
531 | 535 |
} |
532 | 536 |
catch (PDOException $e) |
533 | 537 |
{ |
534 |
- exit('Connection failed' . $e->getMessage()); |
|
538 |
+ exit('Mantis Connection failed: ' . $e->getMessage() . "\n"); |
|
535 | 539 |
} |
536 | 540 |
|
537 | 541 |
$this->setDatabasePrefix(); |
... | ... |
@@ -633,7 +637,7 @@ class mbt_to_tbg extends tbg_converter |
633 | 637 |
$query = ' |
634 | 638 |
SELECT |
635 | 639 |
id, name, description, |
636 |
- (CASE WHEN enabled = 0 THEN 1 ELSE 0) AS locked |
|
640 |
+ (CASE enabled WHEN 0 THEN 1 ELSE 0 END) AS locked |
|
637 | 641 |
FROM ' . $this->mbt_db_prefix . 'project_table |
638 | 642 |
LIMIT ' . $step_size . ' OFFSET ' . $substep; |
639 | 643 |
|
... | ... |
@@ -691,9 +695,9 @@ class mbt_to_tbg extends tbg_converter |
691 | 695 |
$query = ' |
692 | 696 |
SELECT |
693 | 697 |
id, name |
694 |
- FROM ' . $this->mbt_db_prefix . 'builds'; |
|
698 |
+ FROM ' . $this->tbg_db_prefix . 'builds'; |
|
695 | 699 |
$builds = array(); |
696 |
- foreach ($this->tbg_db->query($sql) as $row) |
|
700 |
+ foreach ($this->tbg_db->query($query) as $row) |
|
697 | 701 |
$builds[$row['name']] = $row['id']; |
698 | 702 |
|
699 | 703 |
$query = ' |
... | ... |
@@ -733,7 +737,7 @@ class mbt_to_tbg extends tbg_converter |
733 | 737 |
$query = ' |
734 | 738 |
SELECT |
735 | 739 |
id, name |
736 |
- FROM ' . $this->mbt_db_prefix . 'builds'; |
|
740 |
+ FROM ' . $this->tbg_db_prefix . 'builds'; |
|
737 | 741 |
$builds = array(); |
738 | 742 |
foreach ($this->tbg_db->query($query) as $row) |
739 | 743 |
$builds[$row['name']] = $row['id']; |
... | ... |
@@ -741,15 +745,16 @@ class mbt_to_tbg extends tbg_converter |
741 | 745 |
$query = ' |
742 | 746 |
SELECT |
743 | 747 |
bt.id, bt.project_id, bt.summary AS title, bt.handler_id AS assigned_to, bt.duplicate_id AS duplicate_of, |
744 |
- bt.date_submitted AS posted, bt.last_updated, bt.status AS state, bt.cagegory_id AS category, |
|
748 |
+ bt.date_submitted AS posted, bt.last_updated, bt.status AS state, bt.category_id AS category, bt.resolution, |
|
745 | 749 |
bt.priority, |
746 | 750 |
bt.severity /* NEEDS FIXED */, |
747 | 751 |
(CASE |
748 |
- WHEN bt.reproducability = 10 THEN 12 |
|
749 |
- WHEN bt.reproducability > 30 AND bt.reproducability < 70 THEN 11 |
|
750 |
- WHEN bt.reproducability > 70 AND bt.reproducability < 90 THEN 9 |
|
751 |
- ELSE 0) AS reproducability, |
|
752 |
- IFNULL(btt.steps_to_reproduce, "") AS reproduction_steps |
|
752 |
+ WHEN bt.reproducibility = 10 THEN 12 |
|
753 |
+ WHEN bt.reproducibility > 30 AND bt.reproducibility < 70 THEN 11 |
|
754 |
+ WHEN bt.reproducibility > 70 AND bt.reproducibility < 90 THEN 9 |
|
755 |
+ ELSE 0 |
|
756 |
+ END) AS reproducability, |
|
757 |
+ IFNULL(btt.steps_to_reproduce, "") AS reproduction_steps, |
|
753 | 758 |
IFNULL(btt.description, "") AS description, |
754 | 759 |
version |
755 | 760 |
FROM ' . $this->mbt_db_prefix . 'bug_table AS bt |
... | ... |
@@ -757,7 +762,7 @@ class mbt_to_tbg extends tbg_converter |
757 | 762 |
LIMIT ' . $step_size . ' OFFSET ' . $substep; |
758 | 763 |
|
759 | 764 |
$i = 0; |
760 |
- foreach ($this->mantis_db->query($sql) as $row) |
|
765 |
+ foreach ($this->mantis_db->query($query) as $row) |
|
761 | 766 |
{ |
762 | 767 |
$this->tbg_db->query(' |
763 | 768 |
INSERT INTO ' . $this->tbg_db_prefix . 'issues (id, project_id, title, assigned_to, duplicate_of, posted, last_updated, state, category, resolution, priority, severity, reproducability) |
... | ... |
@@ -769,7 +774,7 @@ class mbt_to_tbg extends tbg_converter |
769 | 774 |
$this->tbg_db->query(' |
770 | 775 |
INSERT INTO (' . $this->tbg_db_prefix . 'builds (name) VALUES (' . $row['version'] . ')'); |
771 | 776 |
|
772 |
- $builds[$row['version']] = $this->db->lastInsertId(); |
|
777 |
+ $builds[$row['version']] = $this->tbg_db->lastInsertId(); |
|
773 | 778 |
} |
774 | 779 |
|
775 | 780 |
$affect_id = $builds[$row['version']]; |
... | ... |
@@ -797,7 +802,7 @@ class mbt_to_tbg extends tbg_converter |
797 | 802 |
bn.id, bn.bug_id AS target_id, bn.last_modified AS updated, bn.date_submitted AS posted, |
798 | 803 |
bn.reporter_id AS updated_by, bn.reporter_id AS posted_by, bnt.note AS content |
799 | 804 |
FROM ' . $this->mbt_db_prefix . 'bugnote_table AS bn |
800 |
- INNER JOIN ' . $this->mbt_db_prefix . 'butnote_text_table AS bnt ON (bn.id = bnt.bug_text_id) |
|
805 |
+ INNER JOIN ' . $this->mbt_db_prefix . 'bugnote_text_table AS bnt ON (bn.id = bnt.id) |
|
801 | 806 |
LIMIT ' . $step_size . ' OFFSET ' . $substep; |
802 | 807 |
|
803 | 808 |
$i = 0; |
... | ... |
@@ -825,7 +830,7 @@ class mbt_to_tbg extends tbg_converter |
825 | 830 |
$query = ' |
826 | 831 |
SELECT |
827 | 832 |
source_bug_id AS parent_id, destination_bug_id AS child_id |
828 |
- FROM ' . $this->mbt_db_prefix . 'bug_relationships_table |
|
833 |
+ FROM ' . $this->mbt_db_prefix . 'bug_relationship_table |
|
829 | 834 |
LIMIT ' . $step_size . ' OFFSET ' . $substep; |
830 | 835 |
|
831 | 836 |
$i = 0; |
832 | 837 |