[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/resources/sql/autopatches/ -> 20140722.appname.php (source)

   1  <?php
   2  
   3  $applications = array(
   4    'Audit',
   5    'Auth',
   6    'Calendar',
   7    'ChatLog',
   8    'Conduit',
   9    'Config',
  10    'Conpherence',
  11    'Countdown',
  12    'Daemons',
  13    'Dashboard',
  14    'Differential',
  15    'Diffusion',
  16    'Diviner',
  17    'Doorkeeper',
  18    'Drydock',
  19    'Fact',
  20    'Feed',
  21    'Files',
  22    'Flags',
  23    'Harbormaster',
  24    'Help',
  25    'Herald',
  26    'Home',
  27    'Legalpad',
  28    'Macro',
  29    'MailingLists',
  30    'Maniphest',
  31    'Applications',
  32    'MetaMTA',
  33    'Notifications',
  34    'Nuance',
  35    'OAuthServer',
  36    'Owners',
  37    'Passphrase',
  38    'Paste',
  39    'People',
  40    'Phame',
  41    'Phlux',
  42    'Pholio',
  43    'Phortune',
  44    'PHPAST',
  45    'Phragment',
  46    'Phrequent',
  47    'Phriction',
  48    'Policy',
  49    'Ponder',
  50    'Project',
  51    'Releeph',
  52    'Repositories',
  53    'Search',
  54    'Settings',
  55    'Slowvote',
  56    'Subscriptions',
  57    'Support',
  58    'System',
  59    'Test',
  60    'Tokens',
  61    'Transactions',
  62    'Typeahead',
  63    'UIExamples',
  64    'XHProf',
  65  );
  66  $map = array();
  67  
  68  foreach ($applications as $application) {
  69    $old_name = 'PhabricatorApplication'.$application;
  70    $new_name = 'Phabricator'.$application.'Application';
  71    $map[$old_name] = $new_name;
  72  }
  73  
  74  
  75  /* -(  User preferences  )--------------------------------------------------- */
  76  
  77  echo "Migrating user preferences...\n";
  78  $table = new PhabricatorUserPreferences();
  79  $conn_w = $table->establishConnection('w');
  80  $pref_pinned = PhabricatorUserPreferences::PREFERENCE_APP_PINNED;
  81  
  82  foreach (new LiskMigrationIterator(new PhabricatorUser()) as $user) {
  83    $user_preferences = $user->loadPreferences();
  84  
  85    $old_pinned_apps = $user_preferences->getPreference($pref_pinned);
  86    $new_pinned_apps = array();
  87  
  88    if (!$old_pinned_apps) {
  89      continue;
  90    }
  91  
  92    foreach ($old_pinned_apps as $pinned_app) {
  93      $new_pinned_apps[] = idx($map, $pinned_app, $pinned_app);
  94    }
  95  
  96    $user_preferences
  97      ->setPreference($pref_pinned, $new_pinned_apps);
  98  
  99    queryfx(
 100      $conn_w,
 101      'UPDATE %T SET preferences = %s WHERE id = %d',
 102      $user_preferences->getTableName(),
 103      json_encode($user_preferences->getPreferences()),
 104      $user_preferences->getID());
 105  }
 106  
 107  
 108  /* -(  Dashboard installs  )------------------------------------------------- */
 109  
 110  echo "Migrating dashboard installs...\n";
 111  $table = new PhabricatorDashboardInstall();
 112  $conn_w = $table->establishConnection('w');
 113  
 114  foreach (new LiskMigrationIterator($table) as $dashboard_install) {
 115    $application = $dashboard_install->getApplicationClass();
 116  
 117    queryfx(
 118      $conn_w,
 119      'UPDATE %T SET applicationClass = %s WHERE id = %d',
 120      $table->getTableName(),
 121      idx($map, $application, $application),
 122      $dashboard_install->getID());
 123  }
 124  
 125  
 126  /* -(  Phabricator configuration  )------------------------------------------ */
 127  
 128  $config_key = 'phabricator.uninstalled-applications';
 129  echo "Migrating `{$config_key}` config...\n";
 130  
 131  $config = PhabricatorConfigEntry::loadConfigEntry($config_key);
 132  $old_config = $config->getValue();
 133  $new_config = array();
 134  
 135  if ($old_config) {
 136    foreach ($old_config as $application => $uninstalled) {
 137      $new_config[idx($map, $application, $application)] = $uninstalled;
 138    }
 139  
 140    $config
 141      ->setIsDeleted(0)
 142      ->setValue($new_config)
 143      ->save();
 144  }
 145  
 146  
 147  /* -(  phabricator.application-settings  )----------------------------------- */
 148  
 149  $config_key = 'phabricator.application-settings';
 150  echo "Migrating `{$config_key}` config...\n";
 151  
 152  $config = PhabricatorConfigEntry::loadConfigEntry($config_key);
 153  $old_config = $config->getValue();
 154  $new_config = array();
 155  
 156  if ($old_config) {
 157    foreach ($old_config as $application => $settings) {
 158      $application = preg_replace('/^PHID-APPS-/', '', $application);
 159      $new_config['PHID-APPS-'.idx($map, $application, $application)] = $settings;
 160    }
 161  
 162    $config
 163      ->setIsDeleted(0)
 164      ->setValue($new_config)
 165      ->save();
 166  }


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