Jeremy D commited on 2011-10-19 19:14:56
Showing 1 changed files, with 60 additions and 33 deletions.
... | ... |
@@ -281,10 +281,16 @@ class tbg_coverter |
281 | 281 |
* |
282 | 282 |
* @param $function The function name we should return to if we can continue. |
283 | 283 |
*/ |
284 |
- function checkTimeout($function) |
|
284 |
+ function checkTimeout($function, $substep, $max_step_size, $count) |
|
285 | 285 |
{ |
286 | 286 |
global $theme; |
287 | 287 |
|
288 |
+ $this->updateSubStep($substep + $max_step_size); |
|
289 |
+ |
|
290 |
+ // Hold on, we had less results than we should have. |
|
291 |
+ if ($max_step_size < $count) |
|
292 |
+ $this->updateStep($function); |
|
293 |
+ |
|
288 | 294 |
// CLI conversions can just continue. |
289 | 295 |
if ($this->is_cli) |
290 | 296 |
{ |
... | ... |
@@ -420,6 +426,7 @@ class mbt_to_tbg extends tbg_converter |
420 | 426 |
LIMIT ' . $substep . ' ' . $step_size; |
421 | 427 |
|
422 | 428 |
// We could let this save up a few inserts then do them at once, but are we really worried about saving queries here? |
429 |
+ $i = 0; |
|
423 | 430 |
foreach ($this->db->query($sql) as $row) |
424 | 431 |
{ |
425 | 432 |
$password = $this->getRandomString(); |
... | ... |
@@ -427,11 +434,11 @@ class mbt_to_tbg extends tbg_converter |
427 | 434 |
$this->db->query(' |
428 | 435 |
INSERT INTO ' . $this->tbg_db_prefix . 'users (id, username, buddyname, realname, email, password, enabled, lastseen, joined) |
429 | 436 |
VALUES (' . $row['id'] . ', "' . $row['username'] . '", "' . $row['buddyname'] . '", "' . $row['realname'] . '", "' . $row['email'] . '", "' . $password . '", ' . $row['enabled'] . ', ' . $row['username'] . ', ' . $row['joined'] . ')'); |
437 |
+ |
|
438 |
+ ++$i; |
|
430 | 439 |
} |
431 | 440 |
|
432 |
- $this->updateSubStep($substep + $step_size); |
|
433 |
- $this->checkTimeout(__FUNCTION__); |
|
434 |
- $this->updateStep(__FUNCTION__); |
|
441 |
+ $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
435 | 442 |
} |
436 | 443 |
|
437 | 444 |
/** |
... | ... |
@@ -450,14 +457,17 @@ class mbt_to_tbg extends tbg_converter |
450 | 457 |
FROM ' . $this->mbt_db_prefix . 'project_table |
451 | 458 |
LIMIT ' . $substep . ' ' . $step_size; |
452 | 459 |
|
460 |
+ $i = 0; |
|
453 | 461 |
foreach ($this->db->query($sql) as $row) |
462 |
+ { |
|
454 | 463 |
$this->db->query(' |
455 | 464 |
INSERT INTO ' . $this->tbg_db_prefix . 'projects (id, name, locked, description) |
456 | 465 |
VALUES (' . $row['id'] . ', "' . $row['name'] . '", ' . $row['locked'] . ', "' . $row['description'] . '")'); |
457 | 466 |
|
458 |
- $this->updateSubStep($substep + $step_size); |
|
459 |
- $this->checkTimeout(__FUNCTION__); |
|
460 |
- $this->updateStep(__FUNCTION__); |
|
467 |
+ ++$i; |
|
468 |
+ } |
|
469 |
+ |
|
470 |
+ $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
461 | 471 |
} |
462 | 472 |
|
463 | 473 |
/** |
... | ... |
@@ -475,14 +485,17 @@ class mbt_to_tbg extends tbg_converter |
475 | 485 |
FROM ' . $this->mbt_db_prefix . 'category_table |
476 | 486 |
LIMIT ' . $substep . ' ' . $step_size; |
477 | 487 |
|
488 |
+ $i = 0; |
|
478 | 489 |
foreach ($this->db->query($sql) as $row) |
490 |
+ { |
|
479 | 491 |
$this->db->query(' |
480 | 492 |
INSERT INTO ' . $this->tbg_db_prefix . 'listtypes (name, itemtype, scope) |
481 | 493 |
VALUES (' . $row['name'] . ', "category", 1)'); |
482 | 494 |
|
483 |
- $this->updateSubStep($substep + $step_size); |
|
484 |
- $this->checkTimeout(__FUNCTION__); |
|
485 |
- $this->updateStep(__FUNCTION__); |
|
495 |
+ ++$i; |
|
496 |
+ } |
|
497 |
+ |
|
498 |
+ $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
486 | 499 |
} |
487 | 500 |
|
488 | 501 |
/** |
... | ... |
@@ -509,6 +522,7 @@ class mbt_to_tbg extends tbg_converter |
509 | 522 |
FROM ' . $this->mbt_db_prefix . 'project_version_table |
510 | 523 |
LIMIT ' . $substep . ' ' . $step_size; |
511 | 524 |
|
525 |
+ $i = 0; |
|
512 | 526 |
foreach ($this->db->query($sql) as $row) |
513 | 527 |
{ |
514 | 528 |
if (isset($builds[$version])) |
... | ... |
@@ -519,11 +533,10 @@ class mbt_to_tbg extends tbg_converter |
519 | 533 |
|
520 | 534 |
$builds[$row['version']] = $this->db->lastInsertId(); |
521 | 535 |
|
536 |
+ ++$i; |
|
522 | 537 |
} |
523 | 538 |
|
524 |
- $this->updateSubStep($substep + $step_size); |
|
525 |
- $this->checkTimeout(__FUNCTION__); |
|
526 |
- $this->updateStep(__FUNCTION__); |
|
539 |
+ $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
527 | 540 |
} |
528 | 541 |
|
529 | 542 |
|
... | ... |
@@ -563,6 +576,7 @@ class mbt_to_tbg extends tbg_converter |
563 | 576 |
LEFT JOIN ' . $this->mbt_db_prefix . 'bug_text_table AS btt ON (btt.id = bt.bug_text_id) |
564 | 577 |
LIMIT ' . $substep . ' ' . $step_size; |
565 | 578 |
|
579 |
+ $i = 0; |
|
566 | 580 |
foreach ($this->db->query($sql) as $row) |
567 | 581 |
{ |
568 | 582 |
$this->db->query(' |
... | ... |
@@ -582,11 +596,11 @@ class mbt_to_tbg extends tbg_converter |
582 | 596 |
|
583 | 597 |
$this->db->query(' |
584 | 598 |
INSERT INTO (' . $this->tbg_db_prefix . 'issueaffectsbuild (id, build) VALUES(' . $row['id'] . ', ' . $affect_id . ')'); |
599 |
+ |
|
600 |
+ ++$i; |
|
585 | 601 |
} |
586 | 602 |
|
587 |
- $this->updateSubStep($substep + $step_size); |
|
588 |
- $this->checkTimeout(__FUNCTION__); |
|
589 |
- $this->updateStep(__FUNCTION__); |
|
603 |
+ $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
590 | 604 |
} |
591 | 605 |
|
592 | 606 |
/** |
... | ... |
@@ -606,14 +620,17 @@ class mbt_to_tbg extends tbg_converter |
606 | 620 |
INNER JOIN ' . $this->mbt_db_prefix . 'butnote_text_table AS bnt ON (bn.id = bnt.bug_text_id) |
607 | 621 |
LIMIT ' . $substep . ' ' . $step_size; |
608 | 622 |
|
623 |
+ $i = 0; |
|
609 | 624 |
foreach ($this->db->query($sql) as $row) |
625 |
+ { |
|
610 | 626 |
$this->db->query(' |
611 | 627 |
INSERT INTO ' . $this->tbg_db_prefix . 'comments (id, target_id, updated, posted, updated_by, posted_by, content) |
612 | 628 |
VALUES (' . $row['id'] . ', ' . $row['target_id'] . ', ' . $row['updated'] . ', ' . $row['posted'] . ', ' . $row['updated_by'] . ', ' . $row['posted_by'] . ', "' . $row['content'] . '")'); |
613 | 629 |
|
614 |
- $this->updateSubStep($substep + $step_size); |
|
615 |
- $this->checkTimeout(__FUNCTION__); |
|
616 |
- $this->updateStep(__FUNCTION__); |
|
630 |
+ ++$i; |
|
631 |
+ } |
|
632 |
+ |
|
633 |
+ $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
617 | 634 |
} |
618 | 635 |
|
619 | 636 |
/** |
... | ... |
@@ -631,15 +648,17 @@ class mbt_to_tbg extends tbg_converter |
631 | 648 |
FROM ' . $this->mbt_db_prefix . 'bug_relationships_table |
632 | 649 |
LIMIT ' . $substep . ' ' . $step_size; |
633 | 650 |
|
651 |
+ $i = 0; |
|
634 | 652 |
foreach ($this->db->query($sql) as $row) |
653 |
+ { |
|
635 | 654 |
$this->db->query(' |
636 | 655 |
INSERT INTO ' . $this->tbg_db_prefix . 'issuerelations (parent_id, child_id) |
637 | 656 |
VALUES (' . $row['parent_id'] . ', ' . $row['child_id'] . ')'); |
638 | 657 |
|
658 |
+ ++$i; |
|
659 |
+ } |
|
639 | 660 |
|
640 |
- $this->updateSubStep($substep + $step_size); |
|
641 |
- $this->checkTimeout(__FUNCTION__); |
|
642 |
- $this->updateStep(__FUNCTION__); |
|
661 |
+ $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
643 | 662 |
} |
644 | 663 |
|
645 | 664 |
/** |
... | ... |
@@ -665,16 +684,20 @@ class mbt_to_tbg extends tbg_converter |
665 | 684 |
FROM ' . $this->mbt_db_prefix . 'bug_file_table |
666 | 685 |
LIMIT ' . $substep . ' ' . $step_size; |
667 | 686 |
|
687 |
+ $i = 0; |
|
668 | 688 |
foreach ($this->db->query($sql) as $row) |
689 |
+ { |
|
669 | 690 |
$this->db->query(' |
670 | 691 |
INSERT INTO ' . $this->tbg_db_prefix . 'files (id, uid, scope, real_filename, original_filename, content_type, content, uploaded_at, description) |
671 | 692 |
VALUES (' . $row['id'] . ', ' . $row['uid'] . ', ' . $row['scope'] . ', "' . $row['real_filename'] . '", "' . $row['original_filename'] . '", "' . $row['content_type'] . '", "' . $row['content'] . '", ' . $row['uploaded_at'] . ', "' . $row['description'] . '")'); |
672 | 693 |
|
673 |
- $this->updateSubStep($substep + $step_size); |
|
674 |
- $this->checkTimeout(__FUNCTION__); |
|
675 |
- $this->updateStep(__FUNCTION__); |
|
694 |
+ ++$i; |
|
676 | 695 |
} |
677 | 696 |
|
697 |
+ $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
698 |
+ } |
|
699 |
+ |
|
700 |
+ // @ TODO: Duplicate function, merge or remove. |
|
678 | 701 |
private function getIssues() |
679 | 702 |
{ |
680 | 703 |
// Get the basics - we'll fix it up in a minute. |
... | ... |
@@ -715,14 +738,16 @@ class mbt_to_tbg extends tbg_converter |
715 | 738 |
UPDATE ' . $this->tbg_prefix . 'issues |
716 | 739 |
SET severity = |
717 | 740 |
CASE severity |
718 |
- WHEN 10 THEN |
|
719 |
- WHEN 20 THEN |
|
720 |
- WHEN 30 THEN |
|
721 |
- WHEN 40 THEN |
|
722 |
- WHEN 50 THEN |
|
723 |
- WHEN 60 THEN |
|
724 |
- WHEN 70 THEN |
|
725 |
- WHEN 80 THEN |
|
741 |
+ WHEN 10 THEN 21 |
|
742 |
+ WHEN 20 THEN 20 |
|
743 |
+ WHEN 30 THEN 20 |
|
744 |
+ WHEN 40 THEN 20 |
|
745 |
+ WHEN 50 THEN 20 |
|
746 |
+ WHEN 60 THEN 21 |
|
747 |
+ WHEN 70 THEN 22 |
|
748 |
+ WHEN 80 THEN 22 |
|
749 |
+ ELSE 21 |
|
750 |
+ END CASE |
|
726 | 751 |
'); |
727 | 752 |
|
728 | 753 |
// Update priority |
... | ... |
@@ -743,6 +768,7 @@ class mbt_to_tbg extends tbg_converter |
743 | 768 |
'); |
744 | 769 |
} |
745 | 770 |
|
771 |
+ // @ TODO: Duplicate function, merge or remove. |
|
746 | 772 |
private function getComments() |
747 | 773 |
{ |
748 | 774 |
$this->db->query(' |
... | ... |
@@ -756,6 +782,7 @@ class mbt_to_tbg extends tbg_converter |
756 | 782 |
|
757 | 783 |
} |
758 | 784 |
|
785 |
+ // @ TODO: Duplicate function, merge or remove. |
|
759 | 786 |
private function getProjects() |
760 | 787 |
{ |
761 | 788 |
$this->db->query(' |
762 | 789 |