Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php $table = new DifferentialRevision(); $conn_w = $table->establishConnection('w'); /..

Decoded Output download

<?php

$table = new DifferentialRevision();
$conn_w = $table->establishConnection('w');

// NOTE: We migrate by revision because the relationship table doesn't have
// an "id" column.

foreach (new LiskMigrationIterator($table) as $revision) {
  $revision_id = $revision->getID();
  $revision_phid = $revision->getPHID();

  echo pht('Migrating reviewers for %s...', "D{$revision_id}")."
";

  $reviewer_phids = queryfx_all(
    $conn_w,
    'SELECT objectPHID FROM %T WHERE revisionID = %d
      AND relation = %s ORDER BY sequence',
    'differential_relationship',
    $revision_id,
    'revw');
  $reviewer_phids = ipull($reviewer_phids, 'objectPHID');

  if (!$reviewer_phids) {
    continue;
  }

  $editor = new PhabricatorEdgeEditor();
  foreach ($reviewer_phids as $dst) {
    if (phid_get_type($dst) == PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) {
      // At least one old install ran into some issues here. Skip the row if we
      // can't figure out what the destination PHID is.
      continue;
    }

    $editor->addEdge(
      $revision_phid,
      DifferentialRevisionHasReviewerEdgeType::EDGECONST,
      $dst,
      array(
        'data' => array(
          'status' => DifferentialReviewerStatus::STATUS_ADDED,
        ),
      ));
  }

  $editor->save();
}

echo pht('Done.')."
";
 ?>

Did this file decode correctly?

Original Code

<?php

$table = new DifferentialRevision();
$conn_w = $table->establishConnection('w');

// NOTE: We migrate by revision because the relationship table doesn't have
// an "id" column.

foreach (new LiskMigrationIterator($table) as $revision) {
  $revision_id = $revision->getID();
  $revision_phid = $revision->getPHID();

  echo pht('Migrating reviewers for %s...', "D{$revision_id}")."\n";

  $reviewer_phids = queryfx_all(
    $conn_w,
    'SELECT objectPHID FROM %T WHERE revisionID = %d
      AND relation = %s ORDER BY sequence',
    'differential_relationship',
    $revision_id,
    'revw');
  $reviewer_phids = ipull($reviewer_phids, 'objectPHID');

  if (!$reviewer_phids) {
    continue;
  }

  $editor = new PhabricatorEdgeEditor();
  foreach ($reviewer_phids as $dst) {
    if (phid_get_type($dst) == PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) {
      // At least one old install ran into some issues here. Skip the row if we
      // can't figure out what the destination PHID is.
      continue;
    }

    $editor->addEdge(
      $revision_phid,
      DifferentialRevisionHasReviewerEdgeType::EDGECONST,
      $dst,
      array(
        'data' => array(
          'status' => DifferentialReviewerStatus::STATUS_ADDED,
        ),
      ));
  }

  $editor->save();
}

echo pht('Done.')."\n";

Function Calls

None

Variables

None

Stats

MD5 81cbbf53f63aebb863fed23256c607fe
Eval Count 0
Decode Time 120 ms