This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace SubPageList; |
||
4 | |||
5 | use Parser; |
||
6 | use RecursiveDirectoryIterator; |
||
7 | use RecursiveIteratorIterator; |
||
8 | use Revision; |
||
9 | use SplFileInfo; |
||
10 | use Title; |
||
11 | use User; |
||
12 | use WikiPage; |
||
13 | |||
14 | /** |
||
15 | * Object containing the logic to set up the SupPageList extension. |
||
16 | * |
||
17 | * @since 1.0 |
||
18 | * |
||
19 | * @licence GNU GPL v2+ |
||
20 | * @author Jeroen De Dauw < [email protected] > |
||
21 | */ |
||
22 | class Setup { |
||
23 | |||
24 | /** |
||
25 | * @var Extension |
||
26 | */ |
||
27 | private $extension; |
||
28 | |||
29 | /** |
||
30 | * @var array[] |
||
31 | */ |
||
32 | private $hooks; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | private $rootDirectory; |
||
38 | |||
39 | /** |
||
40 | * @param Extension $extension |
||
41 | * @param array $hooks |
||
42 | * @param string $rootDirectory |
||
43 | */ |
||
44 | 1 | public function __construct( Extension $extension, array &$hooks, $rootDirectory ) { |
|
45 | 1 | $this->hooks =& $hooks; |
|
46 | 1 | $this->extension = $extension; |
|
47 | 1 | $this->rootDirectory = $rootDirectory; |
|
48 | 1 | } |
|
49 | |||
50 | /** |
||
51 | * Sets up the SubPageList extension. |
||
52 | * |
||
53 | * @since 1.0 |
||
54 | */ |
||
55 | 1 | public function run() { |
|
56 | 1 | $this->registerParserHooks(); |
|
57 | 1 | $this->registerCacheInvalidator(); |
|
58 | 1 | $this->registerUnitTests(); |
|
59 | 1 | } |
|
60 | |||
61 | 24 | private function registerParserHooks() { |
|
62 | 1 | $extension = $this->extension; |
|
63 | |||
64 | /** |
||
65 | * Called when the parser initialises for the first time. |
||
66 | * https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit |
||
67 | */ |
||
68 | 24 | $this->hooks['ParserFirstCallInit'][] = function( Parser &$parser ) use ( $extension ) { |
|
69 | 24 | $hookRegistrant = $extension->getHookRegistrant( $parser ); |
|
70 | |||
71 | 24 | $hookRegistrant->registerFunctionHandler( |
|
72 | 24 | $extension->getCountHookDefinition(), |
|
73 | 24 | $extension->getCountHookHandler() |
|
74 | ); |
||
75 | |||
76 | 24 | $hookRegistrant->registerFunctionHandler( |
|
77 | 24 | $extension->getListHookDefinition(), |
|
78 | 24 | $extension->getListHookHandler() |
|
79 | ); |
||
80 | |||
81 | 24 | $hookRegistrant->registerHookHandler( |
|
82 | 24 | $extension->getCountHookDefinition(), |
|
83 | 24 | $extension->getCountHookHandler() |
|
84 | ); |
||
85 | |||
86 | 24 | $hookRegistrant->registerHookHandler( |
|
87 | 24 | $extension->getListHookDefinition(), |
|
88 | 24 | $extension->getListHookHandler() |
|
89 | ); |
||
90 | |||
91 | 24 | return true; |
|
92 | }; |
||
93 | 1 | } |
|
94 | |||
95 | 4 | private function registerCacheInvalidator() { |
|
96 | 1 | $extension = $this->extension; |
|
97 | |||
98 | /** |
||
99 | * Occurs after a new article has been created. |
||
100 | * https://www.mediawiki.org/wiki/Manual:Hooks/ArticleInsertComplete |
||
101 | */ |
||
102 | 1 | $this->hooks['ArticleInsertComplete'][] |
|
103 | = function( WikiPage $article, User &$user, $text, $summary, $minorEdit, |
||
0 ignored issues
–
show
|
|||
104 | $watchThis, $sectionAnchor, &$flags, Revision $revision ) use ( $extension ) { |
||
0 ignored issues
–
show
|
|||
105 | |||
106 | if ( $extension->getSettings()->get( Settings::AUTO_REFRESH ) ) { |
||
107 | $extension->getCacheInvalidator()->invalidateCaches( $article->getTitle() ); |
||
108 | } |
||
109 | |||
110 | return true; |
||
111 | }; |
||
112 | |||
113 | /** |
||
114 | * Occurs after the delete article request has been processed. |
||
115 | * https://www.mediawiki.org/wiki/Manual:Hooks/ArticleDeleteComplete |
||
116 | */ |
||
117 | 4 | $this->hooks['ArticleDeleteComplete'][] = function( &$article, User &$user, $reason, $id ) use ( $extension ) { |
|
0 ignored issues
–
show
|
|||
118 | 4 | if ( $extension->getSettings()->get( Settings::AUTO_REFRESH ) ) { |
|
119 | $extension->getCacheInvalidator()->invalidateCaches( $article->getTitle() ); |
||
120 | } |
||
121 | |||
122 | 4 | return true; |
|
123 | }; |
||
124 | |||
125 | /** |
||
126 | * Occurs whenever a request to move an article is completed. |
||
127 | * https://www.mediawiki.org/wiki/Manual:Hooks/TitleMoveComplete |
||
128 | */ |
||
129 | $this->hooks['TitleMoveComplete'][] = function( Title &$title, Title &$newTitle, User &$user, $oldId, $newId ) use ( $extension ) { |
||
0 ignored issues
–
show
|
|||
130 | if ( $extension->getSettings()->get( Settings::AUTO_REFRESH ) ) { |
||
131 | $invalidator = $extension->getCacheInvalidator(); |
||
132 | |||
133 | $invalidator->invalidateCaches( $title ); |
||
134 | $invalidator->invalidateCaches( $newTitle ); |
||
135 | } |
||
136 | |||
137 | return true; |
||
138 | }; |
||
139 | 1 | } |
|
140 | |||
141 | 1 | private function registerUnitTests() { |
|
142 | 1 | $rootDirectory = $this->rootDirectory; |
|
143 | |||
144 | /** |
||
145 | * Hook to add PHPUnit test cases. |
||
146 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList |
||
147 | * |
||
148 | * @since 1.0 |
||
149 | * |
||
150 | * @param array $files |
||
151 | * |
||
152 | * @return boolean |
||
153 | */ |
||
154 | $this->hooks['UnitTestsList'][] = function( array &$files ) use ( $rootDirectory ) { |
||
155 | $directoryIterator = new RecursiveDirectoryIterator( $rootDirectory . '/tests/' ); |
||
156 | |||
157 | /** |
||
158 | * @var SplFileInfo $fileInfo |
||
159 | */ |
||
160 | foreach ( new RecursiveIteratorIterator( $directoryIterator ) as $fileInfo ) { |
||
161 | if ( substr( $fileInfo->getFilename(), -8 ) === 'Test.php' ) { |
||
162 | $files[] = $fileInfo->getPathname(); |
||
163 | } |
||
164 | } |
||
165 | |||
166 | return true; |
||
167 | }; |
||
168 | 1 | } |
|
169 | |||
170 | } |
||
171 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.