[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/resources/sql/patches/ -> 20131004.dxreviewers.php (source)

   1  <?php
   2  
   3  $table = new DifferentialRevision();
   4  $conn_w = $table->establishConnection('w');
   5  
   6  // NOTE: We migrate by revision because the relationship table doesn't have
   7  // an "id" column.
   8  
   9  foreach (new LiskMigrationIterator($table) as $revision) {
  10    $revision_id = $revision->getID();
  11    $revision_phid = $revision->getPHID();
  12  
  13    echo "Migrating reviewers for D{$revision_id}...\n";
  14  
  15    $reviewer_phids = queryfx_all(
  16      $conn_w,
  17      'SELECT objectPHID FROM %T WHERE revisionID = %d
  18        AND relation = %s ORDER BY sequence',
  19      'differential_relationship',
  20      $revision_id,
  21      'revw');
  22    $reviewer_phids = ipull($reviewer_phids, 'objectPHID');
  23  
  24    if (!$reviewer_phids) {
  25      continue;
  26    }
  27  
  28    $editor = new PhabricatorEdgeEditor();
  29    foreach ($reviewer_phids as $dst) {
  30      if (phid_get_type($dst) == PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) {
  31        // At least one old install ran into some issues here. Skip the row if we
  32        // can't figure out what the destination PHID is. See here:
  33        // https://github.com/phacility/phabricator/pull/507
  34        continue;
  35      }
  36  
  37      $editor->addEdge(
  38        $revision_phid,
  39        PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER,
  40        $dst,
  41        array(
  42          'data' => array(
  43            'status' => DifferentialReviewerStatus::STATUS_ADDED,
  44          ),
  45        ));
  46    }
  47  
  48    $editor->save();
  49  }
  50  
  51  echo "Done.\n";


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