~ubuntu-branches/ubuntu/wily/phabricator/wily-proposed

« back to all changes in this revision

Viewing changes to phabricator/src/applications/conduit/check/ConduitDeprecatedCallSetupCheck.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2015-02-11 14:13:38 UTC
  • mfrom: (0.18.1) (0.17.1) (0.13.2) (2.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20150211141338-7t6wkyisc5b04ww5
Tags: 0~git20150211-1
* New snapshot release
* updated german translation
* fixed daemons not starting with unprivileged user

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
final class ConduitDeprecatedCallSetupCheck extends PhabricatorSetupCheck {
 
4
 
 
5
  protected function executeChecks() {
 
6
    // NOTE: We still call deprecated methods, so don't enable this until at
 
7
    // least 30 days after fixing T7111, T7112 and T7113.
 
8
    return;
 
9
 
 
10
    $methods = id(new PhabricatorConduitMethodQuery())
 
11
      ->setViewer(PhabricatorUser::getOmnipotentUser())
 
12
      ->withIsDeprecated(true)
 
13
      ->execute();
 
14
    if (!$methods) {
 
15
      return;
 
16
    }
 
17
 
 
18
    $methods = mpull($methods, null, 'getAPIMethodName');
 
19
    $method_names = mpull($methods, 'getAPIMethodName');
 
20
 
 
21
    $table = new PhabricatorConduitMethodCallLog();
 
22
    $conn_r = $table->establishConnection('r');
 
23
 
 
24
    $calls = queryfx_all(
 
25
      $conn_r,
 
26
      'SELECT DISTINCT method FROM %T WHERE dateCreated > %d
 
27
        AND method IN (%Ls)',
 
28
      $table->getTableName(),
 
29
      time() - (60 * 60 * 24 * 30),
 
30
      $method_names);
 
31
    $calls = ipull($calls, 'method', 'method');
 
32
 
 
33
    foreach ($calls as $method_name) {
 
34
      $method = $methods[$method_name];
 
35
 
 
36
      $summary = pht(
 
37
        'Deprecated Conduit method `%s` was called in the last 30 days. '.
 
38
        'You should migrate away from use of this method: it will be '.
 
39
        'removed in a future version of Phabricator.',
 
40
        $method_name);
 
41
 
 
42
      $uri = PhabricatorEnv::getURI('/conduit/log/?methods='.$method_name);
 
43
 
 
44
      $description = $method->getMethodStatusDescription();
 
45
 
 
46
      $message = pht(
 
47
        'Deprecated Conduit method %s was called in the last 30 days. '.
 
48
        'You should migrate away from use of this method: it will be '.
 
49
        'removed in a future version of Phabricator.'.
 
50
        "\n\n".
 
51
        "%s: %s".
 
52
        "\n\n".
 
53
        'If you have already migrated all callers away from this method, '.
 
54
        'you can safely ignore this setup issue.',
 
55
        phutil_tag('tt', array(), $method_name),
 
56
        phutil_tag('tt', array(), $method_name),
 
57
        $description);
 
58
 
 
59
      $this
 
60
        ->newIssue('conduit.deprecated.'.$method_name)
 
61
        ->setShortName(pht('Deprecated Conduit Method'))
 
62
        ->setName(pht('Deprecated Conduit Method "%s" In Use', $method_name))
 
63
        ->setSummary($summary)
 
64
        ->setMessage($message)
 
65
        ->addLink($uri, pht('View Method Call Logs'));
 
66
    }
 
67
  }
 
68
 
 
69
}