[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/resources/sql/autopatches/ -> 20140706.harbormasterdepend.1.php (source)

   1  <?php
   2  
   3  $plan_table = new HarbormasterBuildPlan();
   4  $step_table = new HarbormasterBuildStep();
   5  $conn_w = $plan_table->establishConnection('w');
   6  foreach (new LiskMigrationIterator($plan_table) as $plan) {
   7  
   8    echo pht(
   9      "Migrating build plan %d: %s...\n",
  10      $plan->getID(),
  11      $plan->getName());
  12  
  13    // Load all build steps in order using the step sequence.
  14    $steps = queryfx_all(
  15      $conn_w,
  16      'SELECT id FROM %T WHERE buildPlanPHID = %s ORDER BY sequence ASC;',
  17      $step_table->getTableName(),
  18      $plan->getPHID());
  19  
  20    $previous_step = null;
  21    foreach ($steps as $step) {
  22      $id = $step['id'];
  23  
  24      $loaded_step = id(new HarbormasterBuildStep())->load($id);
  25  
  26      $depends_on = $loaded_step->getDetail('dependsOn');
  27      if ($depends_on !== null) {
  28        // This plan already contains steps with depends_on set, so
  29        // we skip since there's nothing to migrate.
  30        break;
  31      }
  32  
  33      if ($previous_step === null) {
  34        $depends_on = array();
  35      } else {
  36        $depends_on = array($previous_step->getPHID());
  37      }
  38  
  39      $loaded_step->setDetail('dependsOn', $depends_on);
  40      queryfx(
  41        $conn_w,
  42        'UPDATE %T SET details = %s WHERE id = %d',
  43        $step_table->getTableName(),
  44        json_encode($loaded_step->getDetails()),
  45        $loaded_step->getID());
  46  
  47      $previous_step = $loaded_step;
  48  
  49      echo pht(
  50        "  Migrated build step %d.\n",
  51        $loaded_step->getID());
  52    }
  53  
  54  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1