Conditions | 4 |
Paths | 6 |
Total Lines | 32 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 4.25 |
Changes | 0 |
1 | <?php |
||
37 | 1 | public static function getOfflineMessage($external, $message = null) |
|
38 | { |
||
39 | 1 | global $dontUseDbCulprit, $dontUseDbReason, $baseurl; |
|
|
|||
40 | |||
41 | 1 | $smarty = new Smarty(); |
|
42 | 1 | $smarty->assign("baseurl", $baseurl); |
|
43 | 1 | $smarty->assign("toolversion", Environment::getToolVersion()); |
|
44 | |||
45 | 1 | if (!headers_sent()) { |
|
46 | header("HTTP/1.1 503 Service Unavailable"); |
||
47 | } |
||
48 | |||
49 | 1 | if ($external) { |
|
50 | 1 | return $smarty->fetch("offline/external.tpl"); |
|
51 | } |
||
52 | else { |
||
53 | 1 | $hideCulprit = true; |
|
54 | |||
55 | // Use the provided message if possible |
||
56 | 1 | if ($message === null) { |
|
57 | $hideCulprit = false; |
||
58 | $message = $dontUseDbReason; |
||
59 | } |
||
60 | |||
61 | 1 | $smarty->assign("hideCulprit", $hideCulprit); |
|
62 | 1 | $smarty->assign("dontUseDbCulprit", $dontUseDbCulprit); |
|
63 | 1 | $smarty->assign("dontUseDbReason", $message); |
|
64 | 1 | $smarty->assign("alerts", array()); |
|
65 | |||
66 | 1 | return $smarty->fetch("offline/internal.tpl"); |
|
67 | } |
||
68 | } |
||
69 | } |
||
70 |
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state