1 | <?php |
||
33 | class TceMainHook extends AbstractHook |
||
34 | { |
||
35 | /** |
||
36 | * @param array $parameters |
||
37 | * @param DataHandler $parent |
||
38 | * |
||
39 | * @todo implement cache clearing for "clearCache_pageGrandParent", "clearCache_pageSiblingChildren" and |
||
40 | * and "clearCache_disable" http://docs.typo3.org/typo3cms/TSconfigReference/PageTsconfig/TCEmain/Index.html |
||
41 | * @todo find a way how to clear all affected pages after changeing a page title in the main menu or footer |
||
42 | * because it is not possible through the existings hooks to access the correct page tags which needs be cleared from cache |
||
43 | */ |
||
44 | 12 | public function clearCachePostProc(array $parameters, DataHandler $parent) |
|
45 | { |
||
46 | 12 | if ($this->isBackendUserInWorkspace($parent)) { |
|
47 | 1 | return; |
|
48 | } |
||
49 | |||
50 | /** @var Varnish $varnish */ |
||
51 | 11 | $varnish = $this->objectManager->get(Varnish::class); |
|
52 | |||
53 | // delete all Typo3 pages |
||
54 | 11 | if (isset($parameters['cacheCmd']) && $parameters['cacheCmd'] === 'pages') { |
|
55 | 1 | $pageTag = new PageTag('typo3_page'); |
|
|
|||
56 | 1 | $varnish->banByTag($pageTag); |
|
57 | } else { |
||
58 | 10 | $pageId = $this->extractPageIdFromParameters($parameters); |
|
59 | 10 | if ($pageId > 0) { |
|
60 | 3 | $pageIdTag = new PageIdTag($pageId); |
|
61 | 3 | $varnish->banByTag($pageIdTag); |
|
62 | } |
||
63 | } |
||
64 | 11 | } |
|
65 | |||
66 | /** |
||
67 | * extract page id from all variants of parameters that can be given |
||
68 | * |
||
69 | * @param array $parameters |
||
70 | * @return integer |
||
71 | */ |
||
72 | 10 | private function extractPageIdFromParameters(array $parameters) |
|
73 | { |
||
74 | 10 | if (isset($parameters['table']) && $parameters['table'] === 'pages' |
|
75 | 10 | && isset($parameters['uid']) && is_numeric($parameters['uid']) |
|
76 | ) { |
||
77 | 3 | return (integer)$parameters['uid']; |
|
78 | } |
||
79 | 7 | if (isset($parameters['cacheCmd']) && is_numeric($parameters['cacheCmd'])) { |
|
80 | 3 | return (integer)$parameters['cacheCmd']; |
|
81 | } |
||
82 | 4 | if (isset($parameters['uid_page']) && is_numeric($parameters['uid_page'])) { |
|
83 | 3 | return (integer)$parameters['uid_page']; |
|
84 | } |
||
85 | 1 | return 0; |
|
86 | } |
||
87 | |||
88 | /** |
||
89 | * @param DataHandler $parent |
||
90 | * @return boolean |
||
91 | */ |
||
92 | 12 | private function isBackendUserInWorkspace(DataHandler $parent) |
|
99 | } |
||
100 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.