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