@@ -16,118 +16,118 @@ |
||
16 | 16 | */ |
17 | 17 | class ExternalURLCheck implements EnvironmentCheck |
18 | 18 | { |
19 | - /** |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $urls = []; |
|
19 | + /** |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $urls = []; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var Int Timeout in seconds. |
|
26 | - */ |
|
27 | - protected $timeout; |
|
24 | + /** |
|
25 | + * @var Int Timeout in seconds. |
|
26 | + */ |
|
27 | + protected $timeout; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @param string $urls Space-separated list of absolute URLs. |
|
31 | - * @param int $timeout |
|
32 | - */ |
|
33 | - public function __construct($urls, $timeout = 15) |
|
34 | - { |
|
35 | - if ($urls) { |
|
36 | - $this->urls = explode(' ', $urls); |
|
37 | - } |
|
38 | - $this->timeout = $timeout; |
|
39 | - } |
|
29 | + /** |
|
30 | + * @param string $urls Space-separated list of absolute URLs. |
|
31 | + * @param int $timeout |
|
32 | + */ |
|
33 | + public function __construct($urls, $timeout = 15) |
|
34 | + { |
|
35 | + if ($urls) { |
|
36 | + $this->urls = explode(' ', $urls); |
|
37 | + } |
|
38 | + $this->timeout = $timeout; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * {@inheritDoc} |
|
43 | - * |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - public function check() |
|
47 | - { |
|
48 | - $urls = $this->getURLs(); |
|
41 | + /** |
|
42 | + * {@inheritDoc} |
|
43 | + * |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + public function check() |
|
47 | + { |
|
48 | + $urls = $this->getURLs(); |
|
49 | 49 | |
50 | - $chs = []; |
|
51 | - foreach ($urls as $url) { |
|
52 | - $ch = curl_init(); |
|
53 | - $chs[] = $ch; |
|
54 | - curl_setopt_array($ch, $this->getCurlOpts($url)); |
|
55 | - } |
|
56 | - // Parallel execution for faster performance |
|
57 | - $mh = curl_multi_init(); |
|
58 | - foreach ($chs as $ch) { |
|
59 | - curl_multi_add_handle($mh, $ch); |
|
60 | - } |
|
50 | + $chs = []; |
|
51 | + foreach ($urls as $url) { |
|
52 | + $ch = curl_init(); |
|
53 | + $chs[] = $ch; |
|
54 | + curl_setopt_array($ch, $this->getCurlOpts($url)); |
|
55 | + } |
|
56 | + // Parallel execution for faster performance |
|
57 | + $mh = curl_multi_init(); |
|
58 | + foreach ($chs as $ch) { |
|
59 | + curl_multi_add_handle($mh, $ch); |
|
60 | + } |
|
61 | 61 | |
62 | - $active = null; |
|
63 | - // Execute the handles |
|
64 | - do { |
|
65 | - $mrc = curl_multi_exec($mh, $active); |
|
66 | - curl_multi_select($mh); |
|
67 | - } while ($active > 0); |
|
62 | + $active = null; |
|
63 | + // Execute the handles |
|
64 | + do { |
|
65 | + $mrc = curl_multi_exec($mh, $active); |
|
66 | + curl_multi_select($mh); |
|
67 | + } while ($active > 0); |
|
68 | 68 | |
69 | - while ($active && $mrc == CURLM_OK) { |
|
70 | - if (curl_multi_select($mh) != -1) { |
|
71 | - do { |
|
72 | - $mrc = curl_multi_exec($mh, $active); |
|
73 | - } while ($mrc == CURLM_CALL_MULTI_PERFORM); |
|
74 | - } |
|
75 | - } |
|
69 | + while ($active && $mrc == CURLM_OK) { |
|
70 | + if (curl_multi_select($mh) != -1) { |
|
71 | + do { |
|
72 | + $mrc = curl_multi_exec($mh, $active); |
|
73 | + } while ($mrc == CURLM_CALL_MULTI_PERFORM); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - $hasError = false; |
|
78 | - $msgs = []; |
|
79 | - foreach ($chs as $ch) { |
|
80 | - $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
|
81 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
82 | - if (curl_errno($ch) || $code >= 400) { |
|
83 | - $hasError = true; |
|
84 | - $msgs[] = sprintf( |
|
85 | - 'Error retrieving "%s": %s (Code: %s)', |
|
86 | - $url, |
|
87 | - curl_error($ch), |
|
88 | - $code |
|
89 | - ); |
|
90 | - } else { |
|
91 | - $msgs[] = sprintf( |
|
92 | - 'Success retrieving "%s" (Code: %s)', |
|
93 | - $url, |
|
94 | - $code |
|
95 | - ); |
|
96 | - } |
|
97 | - } |
|
77 | + $hasError = false; |
|
78 | + $msgs = []; |
|
79 | + foreach ($chs as $ch) { |
|
80 | + $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
|
81 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
82 | + if (curl_errno($ch) || $code >= 400) { |
|
83 | + $hasError = true; |
|
84 | + $msgs[] = sprintf( |
|
85 | + 'Error retrieving "%s": %s (Code: %s)', |
|
86 | + $url, |
|
87 | + curl_error($ch), |
|
88 | + $code |
|
89 | + ); |
|
90 | + } else { |
|
91 | + $msgs[] = sprintf( |
|
92 | + 'Success retrieving "%s" (Code: %s)', |
|
93 | + $url, |
|
94 | + $code |
|
95 | + ); |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - // Close the handles |
|
100 | - foreach ($chs as $ch) { |
|
101 | - curl_multi_remove_handle($mh, $ch); |
|
102 | - } |
|
103 | - curl_multi_close($mh); |
|
99 | + // Close the handles |
|
100 | + foreach ($chs as $ch) { |
|
101 | + curl_multi_remove_handle($mh, $ch); |
|
102 | + } |
|
103 | + curl_multi_close($mh); |
|
104 | 104 | |
105 | - if ($hasError) { |
|
106 | - return [EnvironmentCheck::ERROR, implode(', ', $msgs)]; |
|
107 | - } |
|
105 | + if ($hasError) { |
|
106 | + return [EnvironmentCheck::ERROR, implode(', ', $msgs)]; |
|
107 | + } |
|
108 | 108 | |
109 | - return [EnvironmentCheck::OK, implode(', ', $msgs)]; |
|
110 | - } |
|
109 | + return [EnvironmentCheck::OK, implode(', ', $msgs)]; |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * @return array |
|
114 | - */ |
|
115 | - protected function getCurlOpts($url) |
|
116 | - { |
|
117 | - return [ |
|
118 | - CURLOPT_URL => $url, |
|
119 | - CURLOPT_HEADER => 0, |
|
120 | - CURLOPT_RETURNTRANSFER => 1, |
|
121 | - CURLOPT_FAILONERROR => 1, |
|
122 | - CURLOPT_TIMEOUT => $this->timeout, |
|
123 | - ]; |
|
124 | - } |
|
112 | + /** |
|
113 | + * @return array |
|
114 | + */ |
|
115 | + protected function getCurlOpts($url) |
|
116 | + { |
|
117 | + return [ |
|
118 | + CURLOPT_URL => $url, |
|
119 | + CURLOPT_HEADER => 0, |
|
120 | + CURLOPT_RETURNTRANSFER => 1, |
|
121 | + CURLOPT_FAILONERROR => 1, |
|
122 | + CURLOPT_TIMEOUT => $this->timeout, |
|
123 | + ]; |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * @return array |
|
128 | - */ |
|
129 | - protected function getURLs() |
|
130 | - { |
|
131 | - return $this->urls; |
|
132 | - } |
|
126 | + /** |
|
127 | + * @return array |
|
128 | + */ |
|
129 | + protected function getURLs() |
|
130 | + { |
|
131 | + return $this->urls; |
|
132 | + } |
|
133 | 133 | } |
@@ -28,124 +28,124 @@ |
||
28 | 28 | */ |
29 | 29 | class FileAgeCheck implements EnvironmentCheck |
30 | 30 | { |
31 | - /** |
|
32 | - * @var int |
|
33 | - */ |
|
34 | - const CHECK_SINGLE = 1; |
|
31 | + /** |
|
32 | + * @var int |
|
33 | + */ |
|
34 | + const CHECK_SINGLE = 1; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var int |
|
38 | - */ |
|
39 | - const CHECK_ALL = 2; |
|
36 | + /** |
|
37 | + * @var int |
|
38 | + */ |
|
39 | + const CHECK_ALL = 2; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Absolute path to a file or folder, compatible with glob(). |
|
43 | - * |
|
44 | - * @var string |
|
45 | - */ |
|
46 | - protected $path; |
|
41 | + /** |
|
42 | + * Absolute path to a file or folder, compatible with glob(). |
|
43 | + * |
|
44 | + * @var string |
|
45 | + */ |
|
46 | + protected $path; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Relative date specification, compatible with strtotime(). |
|
50 | - * |
|
51 | - * @var string |
|
52 | - */ |
|
53 | - protected $relativeAge; |
|
48 | + /** |
|
49 | + * Relative date specification, compatible with strtotime(). |
|
50 | + * |
|
51 | + * @var string |
|
52 | + */ |
|
53 | + protected $relativeAge; |
|
54 | 54 | |
55 | - /** |
|
56 | - * The function to use for checking file age: so filemtime(), filectime(), or fileatime(). |
|
57 | - * |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - protected $checkFn; |
|
55 | + /** |
|
56 | + * The function to use for checking file age: so filemtime(), filectime(), or fileatime(). |
|
57 | + * |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + protected $checkFn; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Constant, check for a single file to match age criteria, or all of them. |
|
64 | - * |
|
65 | - * @var int |
|
66 | - */ |
|
67 | - protected $checkType; |
|
62 | + /** |
|
63 | + * Constant, check for a single file to match age criteria, or all of them. |
|
64 | + * |
|
65 | + * @var int |
|
66 | + */ |
|
67 | + protected $checkType; |
|
68 | 68 | |
69 | - /** |
|
70 | - * Type of comparison (either > or <). |
|
71 | - * |
|
72 | - * @var string |
|
73 | - */ |
|
74 | - protected $compareOperand; |
|
69 | + /** |
|
70 | + * Type of comparison (either > or <). |
|
71 | + * |
|
72 | + * @var string |
|
73 | + */ |
|
74 | + protected $compareOperand; |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string $path |
|
78 | - * @param string $relativeAge |
|
79 | - * @param string $compareOperand |
|
80 | - * @param null|int $checkType |
|
81 | - * @param string $checkFn |
|
82 | - */ |
|
83 | - public function __construct($path, $relativeAge, $compareOperand = '>', $checkType = null, $checkFn = 'filemtime') |
|
84 | - { |
|
85 | - $this->path = $path; |
|
86 | - $this->relativeAge = $relativeAge; |
|
87 | - $this->checkFn = $checkFn; |
|
88 | - $this->checkType = ($checkType) ? $checkType : self::CHECK_SINGLE; |
|
89 | - $this->compareOperand = $compareOperand; |
|
90 | - } |
|
76 | + /** |
|
77 | + * @param string $path |
|
78 | + * @param string $relativeAge |
|
79 | + * @param string $compareOperand |
|
80 | + * @param null|int $checkType |
|
81 | + * @param string $checkFn |
|
82 | + */ |
|
83 | + public function __construct($path, $relativeAge, $compareOperand = '>', $checkType = null, $checkFn = 'filemtime') |
|
84 | + { |
|
85 | + $this->path = $path; |
|
86 | + $this->relativeAge = $relativeAge; |
|
87 | + $this->checkFn = $checkFn; |
|
88 | + $this->checkType = ($checkType) ? $checkType : self::CHECK_SINGLE; |
|
89 | + $this->compareOperand = $compareOperand; |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * {@inheritDoc} |
|
94 | - * |
|
95 | - * @return array |
|
96 | - */ |
|
97 | - public function check() |
|
98 | - { |
|
99 | - $cutoffTime = strtotime($this->relativeAge, DBDatetime::now()->Format('U')); |
|
100 | - $files = $this->getFiles(); |
|
101 | - $invalidFiles = []; |
|
102 | - $validFiles = []; |
|
103 | - $checkFn = $this->checkFn; |
|
104 | - $allValid = true; |
|
105 | - if ($files) { |
|
106 | - foreach ($files as $file) { |
|
107 | - $fileTime = $checkFn($file); |
|
108 | - $valid = ($this->compareOperand == '>') ? ($fileTime >= $cutoffTime) : ($fileTime <= $cutoffTime); |
|
109 | - if ($valid) { |
|
110 | - $validFiles[] = $file; |
|
111 | - } else { |
|
112 | - $invalidFiles[] = $file; |
|
113 | - if ($this->checkType == self::CHECK_ALL) { |
|
114 | - return [ |
|
115 | - EnvironmentCheck::ERROR, |
|
116 | - sprintf( |
|
117 | - 'File "%s" doesn\'t match age check (compare %s: %s, actual: %s)', |
|
118 | - $file, |
|
119 | - $this->compareOperand, |
|
120 | - date('c', $cutoffTime), |
|
121 | - date('c', $fileTime) |
|
122 | - ) |
|
123 | - ]; |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
127 | - } |
|
92 | + /** |
|
93 | + * {@inheritDoc} |
|
94 | + * |
|
95 | + * @return array |
|
96 | + */ |
|
97 | + public function check() |
|
98 | + { |
|
99 | + $cutoffTime = strtotime($this->relativeAge, DBDatetime::now()->Format('U')); |
|
100 | + $files = $this->getFiles(); |
|
101 | + $invalidFiles = []; |
|
102 | + $validFiles = []; |
|
103 | + $checkFn = $this->checkFn; |
|
104 | + $allValid = true; |
|
105 | + if ($files) { |
|
106 | + foreach ($files as $file) { |
|
107 | + $fileTime = $checkFn($file); |
|
108 | + $valid = ($this->compareOperand == '>') ? ($fileTime >= $cutoffTime) : ($fileTime <= $cutoffTime); |
|
109 | + if ($valid) { |
|
110 | + $validFiles[] = $file; |
|
111 | + } else { |
|
112 | + $invalidFiles[] = $file; |
|
113 | + if ($this->checkType == self::CHECK_ALL) { |
|
114 | + return [ |
|
115 | + EnvironmentCheck::ERROR, |
|
116 | + sprintf( |
|
117 | + 'File "%s" doesn\'t match age check (compare %s: %s, actual: %s)', |
|
118 | + $file, |
|
119 | + $this->compareOperand, |
|
120 | + date('c', $cutoffTime), |
|
121 | + date('c', $fileTime) |
|
122 | + ) |
|
123 | + ]; |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | + } |
|
128 | 128 | |
129 | - // If at least one file was valid, count as passed |
|
130 | - if ($this->checkType == self::CHECK_SINGLE && count($invalidFiles) < count($files)) { |
|
131 | - return [EnvironmentCheck::OK, '']; |
|
132 | - } |
|
133 | - if (count($invalidFiles) == 0) { |
|
134 | - return [EnvironmentCheck::OK, '']; |
|
135 | - } |
|
136 | - return [ |
|
137 | - EnvironmentCheck::ERROR, |
|
138 | - sprintf('No files matched criteria (%s %s)', $this->compareOperand, date('c', $cutoffTime)) |
|
139 | - ]; |
|
140 | - } |
|
129 | + // If at least one file was valid, count as passed |
|
130 | + if ($this->checkType == self::CHECK_SINGLE && count($invalidFiles) < count($files)) { |
|
131 | + return [EnvironmentCheck::OK, '']; |
|
132 | + } |
|
133 | + if (count($invalidFiles) == 0) { |
|
134 | + return [EnvironmentCheck::OK, '']; |
|
135 | + } |
|
136 | + return [ |
|
137 | + EnvironmentCheck::ERROR, |
|
138 | + sprintf('No files matched criteria (%s %s)', $this->compareOperand, date('c', $cutoffTime)) |
|
139 | + ]; |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * Gets a list of absolute file paths. |
|
144 | - * |
|
145 | - * @return array |
|
146 | - */ |
|
147 | - protected function getFiles() |
|
148 | - { |
|
149 | - return glob($this->path); |
|
150 | - } |
|
142 | + /** |
|
143 | + * Gets a list of absolute file paths. |
|
144 | + * |
|
145 | + * @return array |
|
146 | + */ |
|
147 | + protected function getFiles() |
|
148 | + { |
|
149 | + return glob($this->path); |
|
150 | + } |
|
151 | 151 | } |
@@ -96,7 +96,7 @@ |
||
96 | 96 | */ |
97 | 97 | public function check() |
98 | 98 | { |
99 | - $cutoffTime = strtotime($this->relativeAge, DBDatetime::now()->Format('U')); |
|
99 | + $cutoffTime = strtotime($this->relativeAge, DBDatetime::now()->Format('U')); |
|
100 | 100 | $files = $this->getFiles(); |
101 | 101 | $invalidFiles = []; |
102 | 102 | $validFiles = []; |
@@ -11,29 +11,29 @@ |
||
11 | 11 | */ |
12 | 12 | class HasClassCheck implements EnvironmentCheck |
13 | 13 | { |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $className; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $className; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @param string $className The name of the class to look for. |
|
21 | - */ |
|
22 | - public function __construct($className) |
|
23 | - { |
|
24 | - $this->className = $className; |
|
25 | - } |
|
19 | + /** |
|
20 | + * @param string $className The name of the class to look for. |
|
21 | + */ |
|
22 | + public function __construct($className) |
|
23 | + { |
|
24 | + $this->className = $className; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * {@inheritDoc} |
|
29 | - * |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - public function check() |
|
33 | - { |
|
34 | - if (class_exists($this->className)) { |
|
35 | - return [EnvironmentCheck::OK, 'Class ' . $this->className.' exists']; |
|
36 | - } |
|
37 | - return [EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist']; |
|
38 | - } |
|
27 | + /** |
|
28 | + * {@inheritDoc} |
|
29 | + * |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + public function check() |
|
33 | + { |
|
34 | + if (class_exists($this->className)) { |
|
35 | + return [EnvironmentCheck::OK, 'Class ' . $this->className.' exists']; |
|
36 | + } |
|
37 | + return [EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist']; |
|
38 | + } |
|
39 | 39 | } |
@@ -32,8 +32,8 @@ |
||
32 | 32 | public function check() |
33 | 33 | { |
34 | 34 | if (class_exists($this->className)) { |
35 | - return [EnvironmentCheck::OK, 'Class ' . $this->className.' exists']; |
|
35 | + return [EnvironmentCheck::OK, 'Class '.$this->className.' exists']; |
|
36 | 36 | } |
37 | - return [EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist']; |
|
37 | + return [EnvironmentCheck::ERROR, 'Class '.$this->className.' doesn\'t exist']; |
|
38 | 38 | } |
39 | 39 | } |
@@ -11,77 +11,77 @@ |
||
11 | 11 | */ |
12 | 12 | class FileWriteableCheck implements EnvironmentCheck |
13 | 13 | { |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $path; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $path; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @param string $path The full path. If a relative path, it will relative to the BASE_PATH. |
|
21 | - */ |
|
22 | - public function __construct($path) |
|
23 | - { |
|
24 | - $this->path = $path; |
|
25 | - } |
|
19 | + /** |
|
20 | + * @param string $path The full path. If a relative path, it will relative to the BASE_PATH. |
|
21 | + */ |
|
22 | + public function __construct($path) |
|
23 | + { |
|
24 | + $this->path = $path; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * {@inheritDoc} |
|
29 | - * |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - public function check() |
|
33 | - { |
|
34 | - if ($this->path[0] == '/') { |
|
35 | - $filename = $this->path; |
|
36 | - } else { |
|
37 | - $filename = BASE_PATH . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $this->path); |
|
38 | - } |
|
27 | + /** |
|
28 | + * {@inheritDoc} |
|
29 | + * |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + public function check() |
|
33 | + { |
|
34 | + if ($this->path[0] == '/') { |
|
35 | + $filename = $this->path; |
|
36 | + } else { |
|
37 | + $filename = BASE_PATH . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $this->path); |
|
38 | + } |
|
39 | 39 | |
40 | - if (file_exists($filename)) { |
|
41 | - $isWriteable = is_writeable($filename); |
|
42 | - } else { |
|
43 | - $isWriteable = is_writeable(dirname($filename)); |
|
44 | - } |
|
40 | + if (file_exists($filename)) { |
|
41 | + $isWriteable = is_writeable($filename); |
|
42 | + } else { |
|
43 | + $isWriteable = is_writeable(dirname($filename)); |
|
44 | + } |
|
45 | 45 | |
46 | - if (!$isWriteable) { |
|
47 | - if (function_exists('posix_getgroups')) { |
|
48 | - $userID = posix_geteuid(); |
|
49 | - $user = posix_getpwuid($userID); |
|
46 | + if (!$isWriteable) { |
|
47 | + if (function_exists('posix_getgroups')) { |
|
48 | + $userID = posix_geteuid(); |
|
49 | + $user = posix_getpwuid($userID); |
|
50 | 50 | |
51 | - $currentOwnerID = fileowner(file_exists($filename) ? $filename : dirname($filename)); |
|
52 | - $currentOwner = posix_getpwuid($currentOwnerID); |
|
51 | + $currentOwnerID = fileowner(file_exists($filename) ? $filename : dirname($filename)); |
|
52 | + $currentOwner = posix_getpwuid($currentOwnerID); |
|
53 | 53 | |
54 | - $message = "User '$user[name]' needs to be able to write to this file:\n$filename\n\nThe file is " |
|
55 | - . "currently owned by '$currentOwner[name]'. "; |
|
54 | + $message = "User '$user[name]' needs to be able to write to this file:\n$filename\n\nThe file is " |
|
55 | + . "currently owned by '$currentOwner[name]'. "; |
|
56 | 56 | |
57 | - if ($user['name'] == $currentOwner['name']) { |
|
58 | - $message .= 'We recommend that you make the file writeable.'; |
|
59 | - } else { |
|
60 | - $groups = posix_getgroups(); |
|
61 | - $groupList = []; |
|
62 | - foreach ($groups as $group) { |
|
63 | - $groupInfo = posix_getgrgid($group); |
|
64 | - if (in_array($currentOwner['name'], $groupInfo['members'])) { |
|
65 | - $groupList[] = $groupInfo['name']; |
|
66 | - } |
|
67 | - } |
|
68 | - if ($groupList) { |
|
69 | - $message .= " We recommend that you make the file group-writeable and change the group to " |
|
70 | - . "one of these groups:\n - " . implode("\n - ", $groupList) |
|
71 | - . "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename"; |
|
72 | - } else { |
|
73 | - $message .= " There is no user-group that contains both the web-server user and the owner " |
|
74 | - . "of this file. Change the ownership of the file, create a new group, or temporarily " |
|
75 | - . "make the file writeable by everyone during the install process."; |
|
76 | - } |
|
77 | - } |
|
78 | - } else { |
|
79 | - $message = "The webserver user needs to be able to write to this file:\n$filename"; |
|
80 | - } |
|
57 | + if ($user['name'] == $currentOwner['name']) { |
|
58 | + $message .= 'We recommend that you make the file writeable.'; |
|
59 | + } else { |
|
60 | + $groups = posix_getgroups(); |
|
61 | + $groupList = []; |
|
62 | + foreach ($groups as $group) { |
|
63 | + $groupInfo = posix_getgrgid($group); |
|
64 | + if (in_array($currentOwner['name'], $groupInfo['members'])) { |
|
65 | + $groupList[] = $groupInfo['name']; |
|
66 | + } |
|
67 | + } |
|
68 | + if ($groupList) { |
|
69 | + $message .= " We recommend that you make the file group-writeable and change the group to " |
|
70 | + . "one of these groups:\n - " . implode("\n - ", $groupList) |
|
71 | + . "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename"; |
|
72 | + } else { |
|
73 | + $message .= " There is no user-group that contains both the web-server user and the owner " |
|
74 | + . "of this file. Change the ownership of the file, create a new group, or temporarily " |
|
75 | + . "make the file writeable by everyone during the install process."; |
|
76 | + } |
|
77 | + } |
|
78 | + } else { |
|
79 | + $message = "The webserver user needs to be able to write to this file:\n$filename"; |
|
80 | + } |
|
81 | 81 | |
82 | - return [EnvironmentCheck::ERROR, $message]; |
|
83 | - } |
|
82 | + return [EnvironmentCheck::ERROR, $message]; |
|
83 | + } |
|
84 | 84 | |
85 | - return [EnvironmentCheck::OK, '']; |
|
86 | - } |
|
85 | + return [EnvironmentCheck::OK, '']; |
|
86 | + } |
|
87 | 87 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | if ($this->path[0] == '/') { |
35 | 35 | $filename = $this->path; |
36 | 36 | } else { |
37 | - $filename = BASE_PATH . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $this->path); |
|
37 | + $filename = BASE_PATH.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $this->path); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | if (file_exists($filename)) { |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | } |
68 | 68 | if ($groupList) { |
69 | 69 | $message .= " We recommend that you make the file group-writeable and change the group to " |
70 | - . "one of these groups:\n - " . implode("\n - ", $groupList) |
|
71 | - . "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename"; |
|
70 | + . "one of these groups:\n - ".implode("\n - ", $groupList) |
|
71 | + . "\n\nFor example:\nchmod g+w $filename\nchgrp ".$groupList[0]." $filename"; |
|
72 | 72 | } else { |
73 | 73 | $message .= " There is no user-group that contains both the web-server user and the owner " |
74 | 74 | . "of this file. Change the ownership of the file, create a new group, or temporarily " |
@@ -16,27 +16,27 @@ |
||
16 | 16 | */ |
17 | 17 | class DevHealthControllerTest extends SapphireTest |
18 | 18 | { |
19 | - /** |
|
20 | - * {@inheritDoc} |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - protected $usesDatabase = true; |
|
19 | + /** |
|
20 | + * {@inheritDoc} |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + protected $usesDatabase = true; |
|
24 | 24 | |
25 | - public function testIndexCreatesChecker() |
|
26 | - { |
|
27 | - $controller = new DevHealthController(); |
|
25 | + public function testIndexCreatesChecker() |
|
26 | + { |
|
27 | + $controller = new DevHealthController(); |
|
28 | 28 | |
29 | - $request = new HTTPRequest('GET', 'example.com'); |
|
29 | + $request = new HTTPRequest('GET', 'example.com'); |
|
30 | 30 | |
31 | - // we need to fake authenticated access as BasicAuth::requireLogin doesn't like empty |
|
32 | - // permission type strings, which is what health check uses. |
|
31 | + // we need to fake authenticated access as BasicAuth::requireLogin doesn't like empty |
|
32 | + // permission type strings, which is what health check uses. |
|
33 | 33 | |
34 | - putenv('ENVCHECK_BASICAUTH_USERNAME="foo"'); |
|
35 | - putenv('ENVCHECK_BASICAUTH_PASSWORD="bar"'); |
|
34 | + putenv('ENVCHECK_BASICAUTH_USERNAME="foo"'); |
|
35 | + putenv('ENVCHECK_BASICAUTH_PASSWORD="bar"'); |
|
36 | 36 | |
37 | - $_SERVER['PHP_AUTH_USER'] = 'foo'; |
|
38 | - $_SERVER['PHP_AUTH_PW'] = 'bar'; |
|
37 | + $_SERVER['PHP_AUTH_USER'] = 'foo'; |
|
38 | + $_SERVER['PHP_AUTH_PW'] = 'bar'; |
|
39 | 39 | |
40 | - $this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request)); |
|
41 | - } |
|
40 | + $this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request)); |
|
41 | + } |
|
42 | 42 | } |
@@ -16,18 +16,18 @@ |
||
16 | 16 | */ |
17 | 17 | class DevCheckControllerTest extends SapphireTest |
18 | 18 | { |
19 | - /** |
|
20 | - * {@inheritDoc} |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - protected $usesDatabase = true; |
|
19 | + /** |
|
20 | + * {@inheritDoc} |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + protected $usesDatabase = true; |
|
24 | 24 | |
25 | - public function testIndexCreatesChecker() |
|
26 | - { |
|
27 | - $controller = new DevCheckController(); |
|
25 | + public function testIndexCreatesChecker() |
|
26 | + { |
|
27 | + $controller = new DevCheckController(); |
|
28 | 28 | |
29 | - $request = new HTTPRequest('GET', 'example.com'); |
|
29 | + $request = new HTTPRequest('GET', 'example.com'); |
|
30 | 30 | |
31 | - $this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request)); |
|
32 | - } |
|
31 | + $this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request)); |
|
32 | + } |
|
33 | 33 | } |
@@ -15,15 +15,15 @@ |
||
15 | 15 | */ |
16 | 16 | class URLCheckTest extends SapphireTest |
17 | 17 | { |
18 | - public function testCheckReportsMissingPages() |
|
19 | - { |
|
20 | - $check = new URLCheck('foo', 'bar'); |
|
18 | + public function testCheckReportsMissingPages() |
|
19 | + { |
|
20 | + $check = new URLCheck('foo', 'bar'); |
|
21 | 21 | |
22 | - $expected = [ |
|
23 | - EnvironmentCheck::ERROR, |
|
24 | - 'Error retrieving "foo" (Code: 404)' |
|
25 | - ]; |
|
22 | + $expected = [ |
|
23 | + EnvironmentCheck::ERROR, |
|
24 | + 'Error retrieving "foo" (Code: 404)' |
|
25 | + ]; |
|
26 | 26 | |
27 | - $this->assertEquals($expected, $check->check()); |
|
28 | - } |
|
27 | + $this->assertEquals($expected, $check->check()); |
|
28 | + } |
|
29 | 29 | } |
@@ -15,24 +15,24 @@ |
||
15 | 15 | */ |
16 | 16 | class FileWritableCheckTest extends SapphireTest |
17 | 17 | { |
18 | - public function testCheckReportsWritablePaths() |
|
19 | - { |
|
20 | - $check = new FileWriteableCheck(TEMP_FOLDER); |
|
18 | + public function testCheckReportsWritablePaths() |
|
19 | + { |
|
20 | + $check = new FileWriteableCheck(TEMP_FOLDER); |
|
21 | 21 | |
22 | - $expected = [ |
|
23 | - EnvironmentCheck::OK, |
|
24 | - '' |
|
25 | - ]; |
|
22 | + $expected = [ |
|
23 | + EnvironmentCheck::OK, |
|
24 | + '' |
|
25 | + ]; |
|
26 | 26 | |
27 | - $this->assertEquals($expected, $check->check()); |
|
28 | - } |
|
27 | + $this->assertEquals($expected, $check->check()); |
|
28 | + } |
|
29 | 29 | |
30 | - public function testCheckReportsNonWritablePaths() |
|
31 | - { |
|
32 | - $check = new FileWriteableCheck('/var'); |
|
30 | + public function testCheckReportsNonWritablePaths() |
|
31 | + { |
|
32 | + $check = new FileWriteableCheck('/var'); |
|
33 | 33 | |
34 | - $result = $check->check(); |
|
34 | + $result = $check->check(); |
|
35 | 35 | |
36 | - $this->assertEquals(EnvironmentCheck::ERROR, $result[0]); |
|
37 | - } |
|
36 | + $this->assertEquals(EnvironmentCheck::ERROR, $result[0]); |
|
37 | + } |
|
38 | 38 | } |
@@ -15,17 +15,17 @@ |
||
15 | 15 | */ |
16 | 16 | class ExternalURLCheckTest extends SapphireTest |
17 | 17 | { |
18 | - public function testCheckReportsMissingPages() |
|
19 | - { |
|
20 | - $this->markTestSkipped('ExternalURLCheck seems faulty on some systems'); |
|
18 | + public function testCheckReportsMissingPages() |
|
19 | + { |
|
20 | + $this->markTestSkipped('ExternalURLCheck seems faulty on some systems'); |
|
21 | 21 | |
22 | - $check = new ExternalURLCheck('http://missing-site/'); |
|
22 | + $check = new ExternalURLCheck('http://missing-site/'); |
|
23 | 23 | |
24 | - $expected = [ |
|
25 | - EnvironmentCheck::ERROR, |
|
26 | - 'Success retrieving "http://missing-site/" (Code: 404)' |
|
27 | - ]; |
|
24 | + $expected = [ |
|
25 | + EnvironmentCheck::ERROR, |
|
26 | + 'Success retrieving "http://missing-site/" (Code: 404)' |
|
27 | + ]; |
|
28 | 28 | |
29 | - $this->assertEquals($expected, $check->check()); |
|
30 | - } |
|
29 | + $this->assertEquals($expected, $check->check()); |
|
30 | + } |
|
31 | 31 | } |