1 | <?php |
||
15 | class CacheHandler { |
||
16 | |||
17 | public static $extensions = [ |
||
18 | 'bmp' => "image/bmp", |
||
19 | 'css' => "text/css", |
||
20 | 'gif' => "image/gif", |
||
21 | 'html' => "text/html", |
||
22 | 'ico' => "image/x-icon", |
||
23 | 'jpeg' => "image/jpeg", |
||
24 | 'jpg' => "image/jpeg", |
||
25 | 'js' => "application/javascript", |
||
26 | 'png' => "image/png", |
||
27 | 'svg' => "image/svg+xml", |
||
28 | 'swf' => "application/x-shockwave-flash", |
||
29 | 'tiff' => "image/tiff", |
||
30 | 'webp' => "image/webp", |
||
31 | 'xml' => "text/xml", |
||
32 | 'eot' => "application/vnd.ms-fontobject", |
||
33 | 'ttf' => "application/font-ttf", |
||
34 | 'woff' => "application/font-woff", |
||
35 | 'woff2' => "application/font-woff2", |
||
36 | 'otf' => "application/font-otf", |
||
37 | ]; |
||
38 | |||
39 | public static $utf8_content_types = [ |
||
40 | "text/css", |
||
41 | "text/html", |
||
42 | "application/javascript", |
||
43 | "image/svg+xml", |
||
44 | "text/xml", |
||
45 | ]; |
||
46 | |||
47 | /** @var Application */ |
||
48 | private $application; |
||
49 | |||
50 | /** @var Config */ |
||
51 | private $config; |
||
52 | |||
53 | /** @var array */ |
||
54 | private $server_vars; |
||
55 | |||
56 | /** |
||
57 | * Constructor |
||
58 | * |
||
59 | * @param Application $app Elgg Application |
||
60 | * @param Config $config Elgg configuration |
||
61 | * @param array $server_vars Server vars |
||
62 | */ |
||
63 | 6 | public function __construct(Application $app, Config $config, $server_vars) { |
|
68 | |||
69 | /** |
||
70 | * Handle a request for a cached view |
||
71 | * |
||
72 | * @param array $path URL path |
||
73 | * @return void |
||
74 | */ |
||
75 | public function handleRequest($path) { |
||
157 | |||
158 | /** |
||
159 | * Parse a request |
||
160 | * |
||
161 | * @param string $path Request URL path |
||
162 | * @return array Cache parameters (empty array if failure) |
||
163 | */ |
||
164 | 6 | public function parsePath($path) { |
|
187 | |||
188 | /** |
||
189 | * Is the view cacheable. Language views are handled specially. |
||
190 | * |
||
191 | * @param string $view View name |
||
192 | * |
||
193 | * @return bool |
||
194 | */ |
||
195 | protected function isCacheableView($view) { |
||
201 | |||
202 | /** |
||
203 | * Send cache headers |
||
204 | * |
||
205 | * @param string $etag ETag value |
||
206 | * @return void |
||
207 | */ |
||
208 | protected function sendCacheHeaders($etag) { |
||
214 | |||
215 | /** |
||
216 | * Send revalidate cache headers |
||
217 | * |
||
218 | * @param string $etag ETag value |
||
219 | * @return void |
||
220 | */ |
||
221 | protected function sendRevalidateHeaders($etag) { |
||
227 | |||
228 | /** |
||
229 | * Send a 304 and exit() if the ETag matches the request |
||
230 | * |
||
231 | * @param string $etag ETag value |
||
232 | * @return void |
||
233 | */ |
||
234 | protected function handle304($etag) { |
||
246 | |||
247 | /** |
||
248 | * Get the content type |
||
249 | * |
||
250 | * @param string $view The view name |
||
251 | * |
||
252 | * @return string|null |
||
253 | */ |
||
254 | protected function getContentType($view) { |
||
263 | |||
264 | /** |
||
265 | * Returns the type of output expected from the view. |
||
266 | * |
||
267 | * - view/name.extension returns "extension" if "extension" is valid |
||
268 | * - css/view return "css" |
||
269 | * - js/view return "js" |
||
270 | * - Otherwise, returns "unknown" |
||
271 | * |
||
272 | * @param string $view The view name |
||
273 | * @return string |
||
274 | */ |
||
275 | private function getViewFileType($view) { |
||
289 | |||
290 | /** |
||
291 | * Get the contents of a view for caching |
||
292 | * |
||
293 | * @param string $view The view name |
||
294 | * @param string $viewtype The viewtype |
||
295 | * @return string |
||
296 | * @see CacheHandler::renderView() |
||
297 | */ |
||
298 | protected function getProcessedView($view, $viewtype) { |
||
314 | |||
315 | /** |
||
316 | * Render a view for caching. Language views are handled specially. |
||
317 | * |
||
318 | * @param string $view The view name |
||
319 | * @param string $viewtype The viewtype |
||
320 | * @return string |
||
321 | */ |
||
322 | protected function renderView($view, $viewtype) { |
||
341 | |||
342 | /** |
||
343 | * Send an error message to requestor |
||
344 | * |
||
345 | * @param string $msg Optional message text |
||
346 | * @return void |
||
347 | */ |
||
348 | protected function send403($msg = 'Cache error: bad request') { |
||
353 | } |
||
354 | |||
355 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: