@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | $username = $request->query->get('username'); |
64 | 64 | |
65 | 65 | if (($project || $queryProject) && $username) { |
66 | - $routeParams = [ 'project'=>($project ?: $queryProject), 'username' => $username ]; |
|
66 | + $routeParams = ['project'=>($project ?: $queryProject), 'username' => $username]; |
|
67 | 67 | return $this->redirectToRoute("EditCounterResult", $routeParams); |
68 | 68 | } elseif (!$project && $queryProject) { |
69 | - return $this->redirectToRoute("EditCounterProject", [ 'project'=>$queryProject ]); |
|
69 | + return $this->redirectToRoute("EditCounterProject", ['project'=>$queryProject]); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $this->init($project); |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | 'rev_small' => $revisionCounts['small'], |
172 | 172 | 'rev_large' => $revisionCounts['large'], |
173 | 173 | 'with_comments' => $revisionCounts['with_comments'], |
174 | - 'without_comments' => $revisionCounts['live'] - $revisionCounts['with_comments'], |
|
174 | + 'without_comments' => $revisionCounts['live']-$revisionCounts['with_comments'], |
|
175 | 175 | 'minor_edits' => $revisionCounts['minor_edits'], |
176 | - 'nonminor_edits' => $revisionCounts['live'] - $revisionCounts['minor_edits'], |
|
176 | + 'nonminor_edits' => $revisionCounts['live']-$revisionCounts['minor_edits'], |
|
177 | 177 | 'auto_edits_total' => array_sum($automatedEditsSummary), |
178 | 178 | |
179 | 179 | // Page counts. |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | // Create the query we're going to run against the meta database |
78 | 78 | $wikiQuery = $this->client->createQueryBuilder(); |
79 | 79 | $wikiQuery |
80 | - ->select([ 'dbName', 'name', 'url', 'lang' ]) |
|
80 | + ->select(['dbName', 'name', 'url', 'lang']) |
|
81 | 81 | ->from('wiki') |
82 | 82 | ->where($wikiQuery->expr()->eq('dbname', ':project')) |
83 | 83 | // The meta database will have the project's URL stored as https://en.wikipedia.org |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $this->dbName = $dbName; |
114 | 114 | $this->url = $url; |
115 | 115 | |
116 | - $dbInfo = [ 'dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url, 'lang' => $lang ]; |
|
116 | + $dbInfo = ['dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url, 'lang' => $lang]; |
|
117 | 117 | $this->dbInfo[$project] = $dbInfo; |
118 | 118 | return $dbInfo; |
119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | public function allProjects() |
125 | 125 | { |
126 | 126 | $wikiQuery = $this->client->createQueryBuilder(); |
127 | - $wikiQuery->select([ 'dbName', 'name', 'url' ])->from('wiki'); |
|
127 | + $wikiQuery->select(['dbName', 'name', 'url'])->from('wiki'); |
|
128 | 128 | $stmt = $wikiQuery->execute(); |
129 | 129 | $out = $stmt->fetchAll(); |
130 | 130 | return $out; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getUserId($usernameOrIp) |
38 | 38 | { |
39 | - $cacheKey = 'userid.' . $usernameOrIp; |
|
39 | + $cacheKey = 'userid.'.$usernameOrIp; |
|
40 | 40 | if ($this->cacheHas($cacheKey)) { |
41 | 41 | return $this->cacheGet($cacheKey); |
42 | 42 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $api = $this->container->get('app.api_helper'); |
65 | 65 | $logger = $this->container->get('logger'); |
66 | 66 | foreach ($this->labsHelper->allProjects() as $project) { |
67 | - $cacheKey = 'topprojects.' . $project['dbName'] . '.' . $username; |
|
67 | + $cacheKey = 'topprojects.'.$project['dbName'].'.'.$username; |
|
68 | 68 | if ($this->cacheHas($cacheKey)) { |
69 | 69 | $total = $this->cacheGet($cacheKey); |
70 | 70 | } else { |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | } |
87 | 87 | $topEditCounts[$project['dbName']] = array_merge($project, ['total' => $total]); |
88 | 88 | } |
89 | - uasort($topEditCounts, function ($a, $b) { |
|
90 | - return $b['total'] - $a['total']; |
|
89 | + uasort($topEditCounts, function($a, $b) { |
|
90 | + return $b['total']-$a['total']; |
|
91 | 91 | }); |
92 | 92 | return array_slice($topEditCounts, 0, $numProjects); |
93 | 93 | } |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | // Count the number of days, accounting for when there's zero or one edit. |
149 | 149 | $revisionCounts['days'] = 0; |
150 | 150 | if ($revisionCounts['first'] && $revisionCounts['last']) { |
151 | - $editingTimeInSeconds = ceil($revisionCounts['last'] - $revisionCounts['first']); |
|
152 | - $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds/(60*60*24) : 1; |
|
151 | + $editingTimeInSeconds = ceil($revisionCounts['last']-$revisionCounts['first']); |
|
152 | + $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds / (60 * 60 * 24) : 1; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | // Format the first and last dates. |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | : 0; |
162 | 162 | |
163 | 163 | // Sum deleted and live to make the total. |
164 | - $revisionCounts['total'] = $revisionCounts['deleted'] + $revisionCounts['live']; |
|
164 | + $revisionCounts['total'] = $revisionCounts['deleted']+$revisionCounts['live']; |
|
165 | 165 | |
166 | 166 | // Calculate the average number of live edits per day. |
167 | 167 | $revisionCounts['avg_per_day'] = 0; |
@@ -208,16 +208,16 @@ discard block |
||
208 | 208 | $results = $resultQuery->fetchAll(); |
209 | 209 | |
210 | 210 | $pageCounts = array_combine( |
211 | - array_map(function ($e) { |
|
211 | + array_map(function($e) { |
|
212 | 212 | return $e['source']; |
213 | 213 | }, $results), |
214 | - array_map(function ($e) { |
|
214 | + array_map(function($e) { |
|
215 | 215 | return $e['value']; |
216 | 216 | }, $results) |
217 | 217 | ); |
218 | 218 | |
219 | 219 | // Total created. |
220 | - $pageCounts['created'] = $pageCounts['created-live'] + $pageCounts['created-deleted']; |
|
220 | + $pageCounts['created'] = $pageCounts['created-live']+$pageCounts['created-deleted']; |
|
221 | 221 | |
222 | 222 | // Calculate the average number of edits per page. |
223 | 223 | $pageCounts['edits_per_page'] = 0; |
@@ -246,17 +246,17 @@ discard block |
||
246 | 246 | $resultQuery->execute(); |
247 | 247 | $results = $resultQuery->fetchAll(); |
248 | 248 | $logCounts = array_combine( |
249 | - array_map(function ($e) { |
|
249 | + array_map(function($e) { |
|
250 | 250 | return $e['source']; |
251 | 251 | }, $results), |
252 | - array_map(function ($e) { |
|
252 | + array_map(function($e) { |
|
253 | 253 | return $e['value']; |
254 | 254 | }, $results) |
255 | 255 | ); |
256 | 256 | |
257 | 257 | // Make sure there is some value for each of the wanted counts. |
258 | 258 | $requiredCounts = [ |
259 | - 'thanks-thank', 'review-approve', 'patrol-patrol','block-block', 'block-unblock', |
|
259 | + 'thanks-thank', 'review-approve', 'patrol-patrol', 'block-block', 'block-unblock', |
|
260 | 260 | 'protect-protect', 'protect-unprotect', 'delete-delete', 'delete-revision', |
261 | 261 | 'delete-restore', 'import-import', 'upload-upload', 'upload-overwrite', |
262 | 262 | ]; |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | // Merge approvals together. |
270 | - $logCounts['review-approve'] = $logCounts['review-approve'] + |
|
271 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
272 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
270 | + $logCounts['review-approve'] = $logCounts['review-approve']+ |
|
271 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
272 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
273 | 273 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
274 | 274 | |
275 | 275 | // Add Commons upload count, if applicable. |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | { |
296 | 296 | $userId = $this->getUserId($username); |
297 | 297 | $sql = "SELECT page_namespace, count(rev_id) AS total |
298 | - FROM ".$this->labsHelper->getTable('revision') ." r |
|
298 | + FROM ".$this->labsHelper->getTable('revision')." r |
|
299 | 299 | JOIN ".$this->labsHelper->getTable('page')." p on r.rev_page = p.page_id |
300 | 300 | WHERE r.rev_user = :id GROUP BY page_namespace"; |
301 | 301 | $resultQuery = $this->replicas->prepare($sql); |
@@ -303,10 +303,10 @@ discard block |
||
303 | 303 | $resultQuery->execute(); |
304 | 304 | $results = $resultQuery->fetchAll(); |
305 | 305 | $namespaceTotals = array_combine( |
306 | - array_map(function ($e) { |
|
306 | + array_map(function($e) { |
|
307 | 307 | return $e['page_namespace']; |
308 | 308 | }, $results), |
309 | - array_map(function ($e) { |
|
309 | + array_map(function($e) { |
|
310 | 310 | return $e['total']; |
311 | 311 | }, $results) |
312 | 312 | ); |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, " |
333 | 333 | . " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, " |
334 | 334 | . " page_title, page_namespace " |
335 | - . " FROM " . $this->labsHelper->getTable('revision', $project['dbName']) |
|
336 | - . " JOIN " . $this->labsHelper->getTable('page', $project['dbName']) |
|
335 | + . " FROM ".$this->labsHelper->getTable('revision', $project['dbName']) |
|
336 | + . " JOIN ".$this->labsHelper->getTable('page', $project['dbName']) |
|
337 | 337 | . " ON (rev_page = page_id)" |
338 | 338 | . " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" |
339 | 339 | . " ORDER BY rev_timestamp DESC" |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | continue; |
349 | 349 | } |
350 | 350 | $revsWithProject = array_map( |
351 | - function (&$item) use ($project) { |
|
351 | + function(&$item) use ($project) { |
|
352 | 352 | $item['project_name'] = $project['name']; |
353 | 353 | $item['project_url'] = $project['url']; |
354 | 354 | $item['project_db_name'] = $project['dbName']; |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | ); |
360 | 360 | $allRevisions = array_merge($allRevisions, $revsWithProject); |
361 | 361 | } |
362 | - usort($allRevisions, function ($a, $b) { |
|
363 | - return $b['rev_timestamp'] - $a['rev_timestamp']; |
|
362 | + usort($allRevisions, function($a, $b) { |
|
363 | + return $b['rev_timestamp']-$a['rev_timestamp']; |
|
364 | 364 | }); |
365 | 365 | return array_slice($allRevisions, 0, $contribCount); |
366 | 366 | } |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | . " MONTH(rev_timestamp) AS `month`," |
383 | 383 | . " page_namespace," |
384 | 384 | . " COUNT(rev_id) AS `count` " |
385 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
386 | - . " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" |
|
385 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
386 | + . " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)" |
|
387 | 387 | . " WHERE rev_user_text = :username" |
388 | 388 | . " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " |
389 | 389 | . " ORDER BY rev_timestamp DESC"; |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | . " SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`," |
440 | 440 | . " page_namespace," |
441 | 441 | . " COUNT(rev_id) AS `count` " |
442 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
443 | - . " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" . |
|
444 | - " WHERE rev_user_text = :username" . |
|
445 | - " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace " . |
|
442 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
443 | + . " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)". |
|
444 | + " WHERE rev_user_text = :username". |
|
445 | + " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace ". |
|
446 | 446 | " ORDER BY rev_timestamp DESC "; |
447 | 447 | $resultQuery = $this->replicas->prepare($sql); |
448 | 448 | $resultQuery->bindParam(":username", $username); |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | . " DAYOFWEEK(rev_timestamp) AS `y`, " |
484 | 484 | . " $xCalc AS `x`, " |
485 | 485 | . " COUNT(rev_id) AS `r` " |
486 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
486 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
487 | 487 | . " WHERE rev_user_text = :username" |
488 | 488 | . " GROUP BY DAYOFWEEK(rev_timestamp), $xCalc " |
489 | 489 | . " "; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function groups($project, $username) |
56 | 56 | { |
57 | 57 | $this->setUp($project); |
58 | - $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
58 | + $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"]; |
|
59 | 59 | $query = new SimpleRequest('query', $params); |
60 | 60 | $result = []; |
61 | 61 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function globalGroups($project, $username) |
75 | 75 | { |
76 | 76 | $this->setUp($project); |
77 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
77 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
78 | 78 | $query = new SimpleRequest('query', $params); |
79 | 79 | $result = []; |
80 | 80 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | $this->setUp($project); |
107 | - $query = new SimpleRequest('query', [ "meta"=>"siteinfo", "siprop"=>"namespaces" ]); |
|
107 | + $query = new SimpleRequest('query', ["meta"=>"siteinfo", "siprop"=>"namespaces"]); |
|
108 | 108 | $namespaces = []; |
109 | 109 | |
110 | 110 | try { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $groups[] = "B"; |
161 | 161 | } |
162 | 162 | if (in_array("steward", $admin["groups"])) { |
163 | - $groups[] = "S" ; |
|
163 | + $groups[] = "S"; |
|
164 | 164 | } |
165 | 165 | if (in_array("checkuser", $admin["groups"])) { |
166 | 166 | $groups[] = "CU"; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | if (in_array("bot", $admin["groups"])) { |
172 | 172 | $groups[] = "Bot"; |
173 | 173 | } |
174 | - $result[ $admin["name"] ] = [ |
|
174 | + $result[$admin["name"]] = [ |
|
175 | 175 | "groups" => implode('/', $groups) |
176 | 176 | ]; |
177 | 177 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $normalized = []; |
247 | 247 | if (isset($result['query']['normalized'])) { |
248 | 248 | array_map( |
249 | - function ($e) use (&$normalized) { |
|
249 | + function($e) use (&$normalized) { |
|
250 | 250 | $normalized[$e['to']] = $e['from']; |
251 | 251 | }, |
252 | 252 | $result['query']['normalized'] |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | ]; |
293 | 293 | |
294 | 294 | // get assessments for this page from the API |
295 | - $assessments = $this->massApi($params, $project, function ($data) { |
|
295 | + $assessments = $this->massApi($params, $project, function($data) { |
|
296 | 296 | return isset($data['pages'][0]['pageassessments']) ? $data['pages'][0]['pageassessments'] : []; |
297 | 297 | }, 'pacontinue')['pages']; |
298 | 298 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $classAttrs = $config['class']['Unknown']; |
317 | 317 | $assessment['class']['value'] = '???'; |
318 | 318 | $assessment['class']['category'] = $classAttrs['category']; |
319 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". $classAttrs['badge']; |
|
319 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".$classAttrs['badge']; |
|
320 | 320 | } else { |
321 | 321 | $classAttrs = $config['class'][$classValue]; |
322 | 322 | $assessment['class'] = [ |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | // add full URL to badge icon |
329 | 329 | if ($classAttrs['badge'] !== '') { |
330 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/" . |
|
330 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". |
|
331 | 331 | $classAttrs['badge']; |
332 | 332 | } |
333 | 333 | |
@@ -376,9 +376,9 @@ discard block |
||
376 | 376 | $config = $this->getAssessmentsConfig(); |
377 | 377 | |
378 | 378 | if (isset($config[$project]['class'][$class])) { |
379 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class'][$class]['badge']; |
|
379 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class'][$class]['badge']; |
|
380 | 380 | } elseif (isset($config[$project]['class']['Unknown'])) { |
381 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class']['Unknown']['badge']; |
|
381 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class']['Unknown']['badge']; |
|
382 | 382 | } else { |
383 | 383 | return ""; |
384 | 384 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
472 | 472 | $innerPromise = $this->api->getRequestAsync($query); |
473 | 473 | |
474 | - $innerPromise->then(function ($result) use (&$data) { |
|
474 | + $innerPromise->then(function($result) use (&$data) { |
|
475 | 475 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
476 | 476 | if (isset($result['error']) || !isset($result['query'])) { |
477 | 477 | return $data['promise']->resolve($data); |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | // calls LabsHelper::databasePrepare() and we've already got that info. |
536 | 536 | if ($this->labsHelper->isLabs()) { |
537 | 537 | // @TODO This assumes too much. Can be removed after T163527. |
538 | - $projectUrl = $projectUrl . '/w/api.php'; |
|
538 | + $projectUrl = $projectUrl.'/w/api.php'; |
|
539 | 539 | $api = MediawikiApi::newFromApiEndpoint($projectUrl); |
540 | 540 | } else { |
541 | 541 | $api = MediawikiApi::newFromPage($projectUrl); |