[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/resources/sql/patches/ -> 20130529.macroauthormig.php (source)

   1  <?php
   2  
   3  echo "Migrating macro authors...\n";
   4  foreach (new LiskMigrationIterator(new PhabricatorFileImageMacro()) as $macro) {
   5    echo "Macro #".$macro->getID()."\n";
   6  
   7    if ($macro->getAuthorPHID()) {
   8      // Already have an author; skip it.
   9      continue;
  10    }
  11  
  12    if (!$macro->getFilePHID()) {
  13      // No valid file; skip it.
  14      continue;
  15    }
  16  
  17    $file = id(new PhabricatorFile())->loadOneWhere(
  18      'phid = %s',
  19      $macro->getFilePHID());
  20  
  21    if (!$file) {
  22      // Couldn't load the file; skip it.
  23      continue;
  24    }
  25  
  26    if (!$file->getAuthorPHID()) {
  27      // File has no author; skip it.
  28      continue;
  29    }
  30  
  31    queryfx(
  32      $macro->establishConnection('w'),
  33      'UPDATE %T SET authorPHID = %s WHERE id = %d',
  34      $macro->getTableName(),
  35      $file->getAuthorPHID(),
  36      $macro->getID());
  37  }
  38  
  39  echo "Done.\n";


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