@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | $this->stopwatch->start($cacheKey, 'XTools'); |
77 | 77 | $api = $this->getMediawikiApi($project); |
78 | - $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
78 | + $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"]; |
|
79 | 79 | $query = new SimpleRequest('query', $params); |
80 | 80 | $result = []; |
81 | 81 | $res = $api->getRequest($query); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | // Create the API query. |
112 | 112 | $api = $this->getMediawikiApi($project); |
113 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
113 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
114 | 114 | $query = new SimpleRequest('query', $params); |
115 | 115 | |
116 | 116 | // Get the result. |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | { |
154 | 154 | $username = $user->getUsername(); |
155 | 155 | |
156 | - $cacheKey = 'pages.' . $project->getDatabaseName() . '.' |
|
157 | - . $username . '.' . $namespace . '.' . $redirects; |
|
156 | + $cacheKey = 'pages.'.$project->getDatabaseName().'.' |
|
157 | + . $username.'.'.$namespace.'.'.$redirects; |
|
158 | 158 | if ($this->cache->hasItem($cacheKey)) { |
159 | 159 | return $this->cache->getItem($cacheKey)->get(); |
160 | 160 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | JOIN $revisionTable ON page_id = rev_page |
213 | 213 | $paJoin |
214 | 214 | WHERE $whereRev AND rev_parent_id = '0' $namespaceConditionRev $redirectCondition |
215 | - " . ($hasPageAssessments ? 'GROUP BY rev_page' : '') . " |
|
215 | + ".($hasPageAssessments ? 'GROUP BY rev_page' : '')." |
|
216 | 216 | ) |
217 | 217 | |
218 | 218 | UNION |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Get this page's database ID. |
62 | - * @return int |
|
62 | + * @return \string|null |
|
63 | 63 | */ |
64 | 64 | public function getId() |
65 | 65 | { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Get this page's length in bytes. |
72 | - * @return int |
|
72 | + * @return \string|null |
|
73 | 73 | */ |
74 | 74 | public function getLength() |
75 | 75 | { |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Get the full URL of this page. |
96 | - * @return string |
|
96 | + * @return \string|null |
|
97 | 97 | */ |
98 | 98 | public function getUrl() |
99 | 99 | { |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Get the numerical ID of the namespace of this page. |
106 | - * @return int |
|
106 | + * @return \string|null |
|
107 | 107 | */ |
108 | 108 | public function getNamespace() |
109 | 109 | { |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | /** |
115 | 115 | * Get the number of page watchers. |
116 | - * @return int |
|
116 | + * @return \string|null |
|
117 | 117 | */ |
118 | 118 | public function getWatchers() |
119 | 119 | { |
@@ -378,7 +378,6 @@ discard block |
||
378 | 378 | |
379 | 379 | /** |
380 | 380 | * Get all wikidata items for the page, not just languages of sister projects |
381 | - * @param Page $page |
|
382 | 381 | * @return int Number of records. |
383 | 382 | */ |
384 | 383 | public function getWikidataItems() |
@@ -388,7 +387,6 @@ discard block |
||
388 | 387 | |
389 | 388 | /** |
390 | 389 | * Count wikidata items for the page, not just languages of sister projects |
391 | - * @param Page $page |
|
392 | 390 | * @return int Number of records. |
393 | 391 | */ |
394 | 392 | public function countWikidataItems() |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | $wikidataInfo = $this->getRepository()->getWikidataInfo($this); |
329 | 329 | |
330 | - $terms = array_map(function ($entry) { |
|
330 | + $terms = array_map(function($entry) { |
|
331 | 331 | return $entry['term']; |
332 | 332 | }, $wikidataInfo); |
333 | 333 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | 'prio' => 2, |
339 | 339 | 'name' => 'Wikidata', |
340 | 340 | 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n |
341 | - 'explanation' => "See: <a target='_blank' " . |
|
341 | + 'explanation' => "See: <a target='_blank' ". |
|
342 | 342 | "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>", |
343 | 343 | ]; |
344 | 344 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | 'prio' => 3, |
349 | 349 | 'name' => 'Wikidata', |
350 | 350 | 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n |
351 | - 'explanation' => "See: <a target='_blank' " . |
|
351 | + 'explanation' => "See: <a target='_blank' ". |
|
352 | 352 | "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>", |
353 | 353 | ]; |
354 | 354 | } |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | $article = $request->query->get('article'); |
84 | 84 | |
85 | 85 | if ($projectQuery != '' && $article != '') { |
86 | - return $this->redirectToRoute('ArticleInfoResult', [ 'project'=>$projectQuery, 'article' => $article ]); |
|
86 | + return $this->redirectToRoute('ArticleInfoResult', ['project'=>$projectQuery, 'article' => $article]); |
|
87 | 87 | } elseif ($article != '') { |
88 | - return $this->redirectToRoute('ArticleInfoProject', [ 'project'=>$projectQuery ]); |
|
88 | + return $this->redirectToRoute('ArticleInfoProject', ['project'=>$projectQuery]); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | if ($projectQuery == '') { |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $this->pageInfo['firstEdit'] = new Edit($this->pageInfo['page'], $this->pageHistory[0]); |
150 | 150 | $this->pageInfo['lastEdit'] = new Edit( |
151 | 151 | $this->pageInfo['page'], |
152 | - $this->pageHistory[$page->getNumRevisions() - 1] |
|
152 | + $this->pageHistory[$page->getNumRevisions()-1] |
|
153 | 153 | ); |
154 | 154 | |
155 | 155 | // NOTE: bots are fetched first in case we want to restrict some stats to humans editors only |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | $userGroupsTable = $this->projectRepo->getTableName($this->dbName, 'user_groups'); |
199 | 199 | $userFromerGroupsTable = $this->projectRepo->getTableName($this->dbName, 'user_former_groups'); |
200 | 200 | $query = "SELECT COUNT(rev_user_text) AS count, rev_user_text AS username, ug_group AS current |
201 | - FROM " . $this->projectRepo->getTableName($this->dbName, 'revision') . " |
|
201 | + FROM " . $this->projectRepo->getTableName($this->dbName, 'revision')." |
|
202 | 202 | LEFT JOIN $userGroupsTable ON rev_user = ug_user |
203 | 203 | LEFT JOIN $userFromerGroupsTable ON rev_user = ufg_user |
204 | - WHERE rev_page = " . $this->pageInfo['page']->getId() . " AND (ug_group = 'bot' OR ufg_group = 'bot') |
|
204 | + WHERE rev_page = ".$this->pageInfo['page']->getId()." AND (ug_group = 'bot' OR ufg_group = 'bot') |
|
205 | 205 | GROUP BY rev_user_text"; |
206 | 206 | $res = $this->conn->query($query)->fetchAll(); |
207 | 207 | |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | $sum = 0; |
211 | 211 | foreach ($res as $bot) { |
212 | 212 | $bots[$bot['username']] = [ |
213 | - 'count' => (int) $bot['count'], |
|
213 | + 'count' => (int)$bot['count'], |
|
214 | 214 | 'current' => $bot['current'] === 'bot' |
215 | 215 | ]; |
216 | 216 | $sum += $bot['count']; |
217 | 217 | } |
218 | 218 | |
219 | - uasort($bots, function ($a, $b) { |
|
220 | - return $b['count'] - $a['count']; |
|
219 | + uasort($bots, function($a, $b) { |
|
220 | + return $b['count']-$a['count']; |
|
221 | 221 | }); |
222 | 222 | |
223 | 223 | $this->pageInfo['general']['bot_revision_count'] = $sum; |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | |
266 | 266 | if ($info['all'] > 1) { |
267 | 267 | // Number of seconds between first and last edit |
268 | - $secs = intval(strtotime($info['last']) - strtotime($info['first']) / $info['all']); |
|
268 | + $secs = intval(strtotime($info['last'])-strtotime($info['first']) / $info['all']); |
|
269 | 269 | |
270 | 270 | // Average time between edits (in days) |
271 | - $this->pageInfo['editors'][$editor]['atbe'] = $secs / ( 60 * 60 * 24 ); |
|
271 | + $this->pageInfo['editors'][$editor]['atbe'] = $secs / (60 * 60 * 24); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | if (count($info['sizes'])) { |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | // First sort editors array by the amount of text they added |
285 | 285 | $topTenEditorsByAdded = $this->pageInfo['editors']; |
286 | - uasort($topTenEditorsByAdded, function ($a, $b) { |
|
286 | + uasort($topTenEditorsByAdded, function($a, $b) { |
|
287 | 287 | if ($a['added'] === $b['added']) { |
288 | 288 | return 0; |
289 | 289 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | // Then build a new array of top 10 editors by added text, |
294 | 294 | // in the data structure needed for the chart |
295 | - $this->pageInfo['topTenEditorsByAdded'] = array_map(function ($editor) { |
|
295 | + $this->pageInfo['topTenEditorsByAdded'] = array_map(function($editor) { |
|
296 | 296 | $added = $this->pageInfo['editors'][$editor]['added']; |
297 | 297 | return [ |
298 | 298 | 'label' => $editor, |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | |
340 | 340 | // Transform to associative array by 'type' |
341 | 341 | foreach ($res as $row) { |
342 | - $data[$row['type'] . '_count'] = $row['value']; |
|
342 | + $data[$row['type'].'_count'] = $row['value']; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | return $data; |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $title = str_replace(' ', '_', $this->pageInfo['page']->getTitle()); |
356 | 356 | $query = "SELECT log_action, log_type, log_timestamp AS timestamp |
357 | 357 | FROM $loggingTable |
358 | - WHERE log_namespace = '" . $this->pageInfo['page']->getNamespace() . "' |
|
358 | + WHERE log_namespace = '".$this->pageInfo['page']->getNamespace()."' |
|
359 | 359 | AND log_title = '$title' AND log_timestamp > 1 |
360 | 360 | AND log_type IN ('delete', 'move', 'protect', 'stable')"; |
361 | 361 | $events = $this->conn->query($query)->fetchAll(); |
@@ -407,14 +407,14 @@ discard block |
||
407 | 407 | return $rev['length']; |
408 | 408 | } |
409 | 409 | |
410 | - $lastRev = $this->pageHistory[$revIndex - 1]; |
|
410 | + $lastRev = $this->pageHistory[$revIndex-1]; |
|
411 | 411 | |
412 | 412 | // TODO: Remove once T101631 is resolved |
413 | 413 | // Treat as zero change in size if length of previous edit is missing |
414 | 414 | if ($lastRev['length'] === null) { |
415 | 415 | return 0; |
416 | 416 | } else { |
417 | - return $rev['length'] - $lastRev['length']; |
|
417 | + return $rev['length']-$lastRev['length']; |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
@@ -434,10 +434,10 @@ discard block |
||
434 | 434 | |
435 | 435 | // Get UNIX timestamp of the first day of the month of the first edit |
436 | 436 | // This is used as a comparison when building our array of per-month stats |
437 | - $firstEditMonth = mktime(0, 0, 0, (int) $firstEdit->getMonth(), 1, $firstEdit->getYear()); |
|
437 | + $firstEditMonth = mktime(0, 0, 0, (int)$firstEdit->getMonth(), 1, $firstEdit->getYear()); |
|
438 | 438 | |
439 | 439 | $lastEdit = $this->pageInfo['lastEdit']; |
440 | - $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[ $revisionCount - 2 ]; |
|
440 | + $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[$revisionCount-2]; |
|
441 | 441 | |
442 | 442 | // Now we can start our master array. This one will be HUGE! |
443 | 443 | $data = [ |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | // Increment year and month counts for all edits |
509 | 509 | $data['year_count'][$edit->getYear()]['all']++; |
510 | 510 | $data['year_count'][$edit->getYear()]['months'][$edit->getMonth()]['all']++; |
511 | - $data['year_count'][$edit->getYear()]['size'] = (int) $rev['length']; |
|
511 | + $data['year_count'][$edit->getYear()]['size'] = (int)$rev['length']; |
|
512 | 512 | |
513 | 513 | $editsThisMonth = $data['year_count'][$edit->getYear()]['months'][$edit->getMonth()]['all']; |
514 | 514 | if ($editsThisMonth > $data['max_edits_per_month']) { |
@@ -552,9 +552,9 @@ discard block |
||
552 | 552 | } |
553 | 553 | |
554 | 554 | // determine if the next revision was a revert |
555 | - $nextRevision = isset($this->pageHistory[$i + 1]) ? $this->pageHistory[$i + 1] : null; |
|
555 | + $nextRevision = isset($this->pageHistory[$i+1]) ? $this->pageHistory[$i+1] : null; |
|
556 | 556 | $nextRevisionIsRevert = $nextRevision && |
557 | - $this->getDiffSize($i + 1) === -$edit->getSize() && |
|
557 | + $this->getDiffSize($i+1) === -$edit->getSize() && |
|
558 | 558 | $this->aeh->isRevert($nextRevision['comment']); |
559 | 559 | |
560 | 560 | // don't count this edit as content removal if the next edit reverted it |