1 | <?php |
||
27 | class IdentificationVerifier |
||
28 | { |
||
29 | /** |
||
30 | * This field is an array of parameters, in key => value format, that should be appended to the Meta Wikimedia |
||
31 | * Web Service Endpoint URL to query if a user is listed on the Identification Noticeboard. Note that URL encoding |
||
32 | * of these values is *not* necessary; this is done automatically. |
||
33 | * |
||
34 | * @var string[] |
||
35 | * @category Security-Critical |
||
36 | */ |
||
37 | private static $apiQueryParameters = array( |
||
38 | 'action' => 'query', |
||
39 | 'format' => 'json', |
||
40 | 'prop' => 'links', |
||
41 | 'titles' => 'Access to nonpublic information policy/Noticeboard', |
||
42 | // Username of the user to be checked, with User: prefix, goes here! Set in isIdentifiedOnWiki() |
||
43 | 'pltitles' => '', |
||
44 | ); |
||
45 | /** @var HttpHelper */ |
||
46 | private $httpHelper; |
||
47 | /** @var SiteConfiguration */ |
||
48 | private $siteConfiguration; |
||
49 | /** @var PdoDatabase */ |
||
50 | private $dbObject; |
||
51 | |||
52 | /** |
||
53 | * IdentificationVerifier constructor. |
||
54 | * |
||
55 | * @param HttpHelper $httpHelper |
||
56 | * @param SiteConfiguration $siteConfiguration |
||
57 | * @param PdoDatabase $dbObject |
||
58 | */ |
||
59 | 1 | public function __construct(HttpHelper $httpHelper, SiteConfiguration $siteConfiguration, PdoDatabase $dbObject) |
|
65 | |||
66 | /** |
||
67 | * Checks if the given user is identified to the Wikimedia Foundation. |
||
68 | * |
||
69 | * @param string $onWikiName The Wikipedia username of the user |
||
70 | * |
||
71 | * @return bool |
||
72 | * @category Security-Critical |
||
73 | */ |
||
74 | public function isUserIdentified($onWikiName) |
||
90 | |||
91 | /** |
||
92 | * Checks if the given user has a valid entry in the idcache table. |
||
93 | * |
||
94 | * @param string $onWikiName The Wikipedia username of the user |
||
95 | * |
||
96 | * @return bool |
||
97 | * @category Security-Critical |
||
98 | */ |
||
99 | private function checkIdentificationCache($onWikiName) |
||
120 | |||
121 | /** |
||
122 | * Does pretty much exactly what it says on the label - this method will clear all expired idcache entries from the |
||
123 | * idcache table. Meant to be called periodically by a maintenance script. |
||
124 | * |
||
125 | * @param SiteConfiguration $siteConfiguration |
||
126 | * @param PdoDatabase $dbObject |
||
127 | * |
||
128 | * @return void |
||
129 | */ |
||
130 | public static function clearExpiredCacheEntries(SiteConfiguration $siteConfiguration, PdoDatabase $dbObject) |
||
140 | |||
141 | /** |
||
142 | * This method will add an entry to the idcache that the given Wikipedia user has been verified as identified. This |
||
143 | * is so we don't have to hit the API every single time we check. The cache entry is valid for as long as specified |
||
144 | * in the ACC configuration (validity enforced by checkIdentificationCache() and clearExpiredCacheEntries()). |
||
145 | * |
||
146 | * @param string $onWikiName The Wikipedia username of the user |
||
147 | * |
||
148 | * @return void |
||
149 | * @category Security-Critical |
||
150 | */ |
||
151 | private function cacheIdentificationStatus($onWikiName) |
||
166 | |||
167 | /** |
||
168 | * Queries the Wikimedia API to determine if the specified user is listed on the identification noticeboard. |
||
169 | * |
||
170 | * @param string $onWikiName The Wikipedia username of the user |
||
171 | * |
||
172 | * @return bool |
||
173 | * @throws EnvironmentException |
||
174 | * @category Security-Critical |
||
175 | */ |
||
176 | 1 | private function isIdentifiedOnWiki($onWikiName) |
|
202 | } |
||
203 |
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.