~ubuntu-branches/ubuntu/vivid/phabricator/vivid-proposed

« back to all changes in this revision

Viewing changes to phabricator/src/applications/config/check/PhabricatorExtraConfigSetupCheck.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2015-01-29 00:15:58 UTC
  • mfrom: (0.16.1) (0.15.1) (0.12.2) (2.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20150129001558-na84707j70qqla7z
Tags: 0~git20150129-1
* New snapshot release
* restricted access to local config file (closes: #775479)
* moved local config file to /var/lib/phabricator (closes: #775478)
* switched mysql-server dependency to recommends (closes: #773536)
* use /run instead of /var/run (closes: #775803)
* prevent package reinstall from overwritting local changes (closes: #776288)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
final class PhabricatorExtraConfigSetupCheck extends PhabricatorSetupCheck {
 
4
 
 
5
  protected function executeChecks() {
 
6
    $ancient_config = self::getAncientConfig();
 
7
 
 
8
    $all_keys = PhabricatorEnv::getAllConfigKeys();
 
9
    $all_keys = array_keys($all_keys);
 
10
    sort($all_keys);
 
11
 
 
12
    $defined_keys = PhabricatorApplicationConfigOptions::loadAllOptions();
 
13
 
 
14
    foreach ($all_keys as $key) {
 
15
      if (isset($defined_keys[$key])) {
 
16
        continue;
 
17
      }
 
18
 
 
19
      if (isset($ancient_config[$key])) {
 
20
        $summary = pht(
 
21
          'This option has been removed. You may delete it at your '.
 
22
          'convenience.');
 
23
        $message = pht(
 
24
          "The configuration option '%s' has been removed. You may delete ".
 
25
          "it at your convenience.".
 
26
          "\n\n%s",
 
27
          $key,
 
28
          $ancient_config[$key]);
 
29
        $short = pht('Obsolete Config');
 
30
        $name = pht('Obsolete Configuration Option "%s"', $key);
 
31
      } else {
 
32
        $summary = pht('This option is not recognized. It may be misspelled.');
 
33
        $message = pht(
 
34
          "The configuration option '%s' is not recognized. It may be ".
 
35
          "misspelled, or it might have existed in an older version of ".
 
36
          "Phabricator. It has no effect, and should be corrected or deleted.",
 
37
          $key);
 
38
        $short = pht('Unknown Config');
 
39
        $name = pht('Unknown Configuration Option "%s"', $key);
 
40
      }
 
41
 
 
42
      $issue = $this->newIssue('config.unknown.'.$key)
 
43
        ->setShortName($short)
 
44
        ->setName($name)
 
45
        ->setSummary($summary);
 
46
 
 
47
      $stack = PhabricatorEnv::getConfigSourceStack();
 
48
      $stack = $stack->getStack();
 
49
 
 
50
      $found = array();
 
51
      $found_local = false;
 
52
      $found_database = false;
 
53
 
 
54
      foreach ($stack as $source_key => $source) {
 
55
        $value = $source->getKeys(array($key));
 
56
        if ($value) {
 
57
          $found[] = $source->getName();
 
58
          if ($source instanceof PhabricatorConfigDatabaseSource) {
 
59
            $found_database = true;
 
60
          }
 
61
          if ($source instanceof PhabricatorConfigLocalSource) {
 
62
            $found_local = true;
 
63
          }
 
64
        }
 
65
      }
 
66
 
 
67
      $message = $message."\n\n".pht(
 
68
        'This configuration value is defined in these %d '.
 
69
        'configuration source(s): %s.',
 
70
        count($found),
 
71
        implode(', ', $found));
 
72
      $issue->setMessage($message);
 
73
 
 
74
      if ($found_local) {
 
75
        $command = csprintf('phabricator/ $ ./bin/config delete %s', $key);
 
76
        $issue->addCommand($command);
 
77
      }
 
78
 
 
79
      if ($found_database) {
 
80
        $issue->addPhabricatorConfig($key);
 
81
      }
 
82
    }
 
83
  }
 
84
 
 
85
  /**
 
86
   * Return a map of deleted config options. Keys are option keys; values are
 
87
   * explanations of what happened to the option.
 
88
   */
 
89
  public static function getAncientConfig() {
 
90
    $reason_auth = pht(
 
91
      'This option has been migrated to the "Auth" application. Your old '.
 
92
      'configuration is still in effect, but now stored in "Auth" instead of '.
 
93
      'configuration. Going forward, you can manage authentication from '.
 
94
      'the web UI.');
 
95
 
 
96
    $auth_config = array(
 
97
      'controller.oauth-registration',
 
98
      'auth.password-auth-enabled',
 
99
      'facebook.auth-enabled',
 
100
      'facebook.registration-enabled',
 
101
      'facebook.auth-permanent',
 
102
      'facebook.application-id',
 
103
      'facebook.application-secret',
 
104
      'facebook.require-https-auth',
 
105
      'github.auth-enabled',
 
106
      'github.registration-enabled',
 
107
      'github.auth-permanent',
 
108
      'github.application-id',
 
109
      'github.application-secret',
 
110
      'google.auth-enabled',
 
111
      'google.registration-enabled',
 
112
      'google.auth-permanent',
 
113
      'google.application-id',
 
114
      'google.application-secret',
 
115
      'ldap.auth-enabled',
 
116
      'ldap.hostname',
 
117
      'ldap.port',
 
118
      'ldap.base_dn',
 
119
      'ldap.search_attribute',
 
120
      'ldap.search-first',
 
121
      'ldap.username-attribute',
 
122
      'ldap.real_name_attributes',
 
123
      'ldap.activedirectory_domain',
 
124
      'ldap.version',
 
125
      'ldap.referrals',
 
126
      'ldap.anonymous-user-name',
 
127
      'ldap.anonymous-user-password',
 
128
      'ldap.start-tls',
 
129
      'disqus.auth-enabled',
 
130
      'disqus.registration-enabled',
 
131
      'disqus.auth-permanent',
 
132
      'disqus.application-id',
 
133
      'disqus.application-secret',
 
134
      'phabricator.oauth-uri',
 
135
      'phabricator.auth-enabled',
 
136
      'phabricator.registration-enabled',
 
137
      'phabricator.auth-permanent',
 
138
      'phabricator.application-id',
 
139
      'phabricator.application-secret',
 
140
    );
 
141
 
 
142
    $ancient_config = array_fill_keys($auth_config, $reason_auth);
 
143
 
 
144
    $markup_reason = pht(
 
145
      'Custom remarkup rules are now added by subclassing '.
 
146
      'PhabricatorRemarkupCustomInlineRule or '.
 
147
      'PhabricatorRemarkupCustomBlockRule.');
 
148
 
 
149
    $session_reason = pht(
 
150
      'Sessions now expire and are garbage collected rather than having an '.
 
151
      'arbitrary concurrency limit.');
 
152
 
 
153
    $differential_field_reason = pht(
 
154
      'All Differential fields are now managed through the configuration '.
 
155
      'option "%s". Use that option to configure which fields are shown.',
 
156
      'differential.fields');
 
157
 
 
158
    $ancient_config += array(
 
159
      'phid.external-loaders' =>
 
160
        pht(
 
161
          'External loaders have been replaced. Extend `PhabricatorPHIDType` '.
 
162
          'to implement new PHID and handle types.'),
 
163
      'maniphest.custom-task-extensions-class' =>
 
164
        pht(
 
165
          'Maniphest fields are now loaded automatically. You can configure '.
 
166
          'them with `maniphest.fields`.'),
 
167
      'maniphest.custom-fields' =>
 
168
        pht(
 
169
          'Maniphest fields are now defined in '.
 
170
          '`maniphest.custom-field-definitions`. Existing definitions have '.
 
171
          'been migrated.'),
 
172
      'differential.custom-remarkup-rules' => $markup_reason,
 
173
      'differential.custom-remarkup-block-rules' => $markup_reason,
 
174
      'auth.sshkeys.enabled' => pht(
 
175
        'SSH keys are now actually useful, so they are always enabled.'),
 
176
      'differential.anonymous-access' => pht(
 
177
        'Phabricator now has meaningful global access controls. See '.
 
178
        '`policy.allow-public`.'),
 
179
      'celerity.resource-path' => pht(
 
180
        'An alternate resource map is no longer supported. Instead, use '.
 
181
        'multiple maps. See T4222.'),
 
182
      'metamta.send-immediately' => pht(
 
183
        'Mail is now always delivered by the daemons.'),
 
184
      'auth.sessions.conduit' => $session_reason,
 
185
      'auth.sessions.web' => $session_reason,
 
186
      'tokenizer.ondemand' => pht(
 
187
        'Phabricator now manages typeahead strategies automatically.'),
 
188
      'differential.revision-custom-detail-renderer' => pht(
 
189
        'Obsolete; use standard rendering events instead.'),
 
190
      'differential.show-host-field' => $differential_field_reason,
 
191
      'differential.show-test-plan-field' => $differential_field_reason,
 
192
      'differential.field-selector' => $differential_field_reason,
 
193
      'phabricator.show-beta-applications' => pht(
 
194
        'This option has been renamed to `phabricator.show-prototypes` '.
 
195
        'to emphasize the unfinished nature of many prototype applications. '.
 
196
        'Your existing setting has been migrated.'),
 
197
      'notification.user' => pht(
 
198
        'The notification server no longer requires root permissions. Start '.
 
199
        'the server as the user you want it to run under.'),
 
200
      'notification.debug' => pht(
 
201
        'Notifications no longer have a dedicated debugging mode.'),
 
202
    );
 
203
 
 
204
    return $ancient_config;
 
205
  }
 
206
}