@@ -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 == '') { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $this->pageInfo['firstEdit'] = new Edit($this->pageInfo['page'], $this->pageHistory[0]); |
154 | 154 | $this->pageInfo['lastEdit'] = new Edit( |
155 | 155 | $this->pageInfo['page'], |
156 | - $this->pageHistory[$page->getNumRevisions() - 1] |
|
156 | + $this->pageHistory[$page->getNumRevisions()-1] |
|
157 | 157 | ); |
158 | 158 | |
159 | 159 | // NOTE: bots are fetched first in case we want to restrict some stats to humans editors only |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | $userGroupsTable = $this->projectRepo->getTableName($this->dbName, 'user_groups'); |
216 | 216 | $userFromerGroupsTable = $this->projectRepo->getTableName($this->dbName, 'user_former_groups'); |
217 | 217 | $query = "SELECT COUNT(rev_user_text) AS count, rev_user_text AS username, ug_group AS current |
218 | - FROM " . $this->projectRepo->getTableName($this->dbName, 'revision') . " |
|
218 | + FROM " . $this->projectRepo->getTableName($this->dbName, 'revision')." |
|
219 | 219 | LEFT JOIN $userGroupsTable ON rev_user = ug_user |
220 | 220 | LEFT JOIN $userFromerGroupsTable ON rev_user = ufg_user |
221 | - WHERE rev_page = " . $this->pageInfo['page']->getId() . " AND (ug_group = 'bot' OR ufg_group = 'bot') |
|
221 | + WHERE rev_page = ".$this->pageInfo['page']->getId()." AND (ug_group = 'bot' OR ufg_group = 'bot') |
|
222 | 222 | GROUP BY rev_user_text"; |
223 | 223 | $res = $this->conn->query($query)->fetchAll(); |
224 | 224 | |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | $sum = 0; |
228 | 228 | foreach ($res as $bot) { |
229 | 229 | $bots[$bot['username']] = [ |
230 | - 'count' => (int) $bot['count'], |
|
230 | + 'count' => (int)$bot['count'], |
|
231 | 231 | 'current' => $bot['current'] === 'bot' |
232 | 232 | ]; |
233 | 233 | $sum += $bot['count']; |
234 | 234 | } |
235 | 235 | |
236 | - uasort($bots, function ($a, $b) { |
|
237 | - return $b['count'] - $a['count']; |
|
236 | + uasort($bots, function($a, $b) { |
|
237 | + return $b['count']-$a['count']; |
|
238 | 238 | }); |
239 | 239 | |
240 | 240 | $this->pageInfo['general']['bot_revision_count'] = $sum; |
@@ -282,10 +282,10 @@ discard block |
||
282 | 282 | |
283 | 283 | if ($info['all'] > 1) { |
284 | 284 | // Number of seconds between first and last edit |
285 | - $secs = intval(strtotime($info['last']) - strtotime($info['first']) / $info['all']); |
|
285 | + $secs = intval(strtotime($info['last'])-strtotime($info['first']) / $info['all']); |
|
286 | 286 | |
287 | 287 | // Average time between edits (in days) |
288 | - $this->pageInfo['editors'][$editor]['atbe'] = $secs / ( 60 * 60 * 24 ); |
|
288 | + $this->pageInfo['editors'][$editor]['atbe'] = $secs / (60 * 60 * 24); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | if (count($info['sizes'])) { |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | |
301 | 301 | // First sort editors array by the amount of text they added |
302 | 302 | $topTenEditorsByAdded = $this->pageInfo['editors']; |
303 | - uasort($topTenEditorsByAdded, function ($a, $b) { |
|
303 | + uasort($topTenEditorsByAdded, function($a, $b) { |
|
304 | 304 | if ($a['added'] === $b['added']) { |
305 | 305 | return 0; |
306 | 306 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | // Then build a new array of top 10 editors by added text, |
311 | 311 | // in the data structure needed for the chart |
312 | - $this->pageInfo['topTenEditorsByAdded'] = array_map(function ($editor) { |
|
312 | + $this->pageInfo['topTenEditorsByAdded'] = array_map(function($editor) { |
|
313 | 313 | $added = $this->pageInfo['editors'][$editor]['added']; |
314 | 314 | return [ |
315 | 315 | 'label' => $editor, |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | |
357 | 357 | // Transform to associative array by 'type' |
358 | 358 | foreach ($res as $row) { |
359 | - $data[$row['type'] . '_count'] = $row['value']; |
|
359 | + $data[$row['type'].'_count'] = $row['value']; |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | return $data; |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $title = str_replace(' ', '_', $this->pageInfo['page']->getTitle()); |
373 | 373 | $query = "SELECT log_action, log_type, log_timestamp AS timestamp |
374 | 374 | FROM $loggingTable |
375 | - WHERE log_namespace = '" . $this->pageInfo['page']->getNamespace() . "' |
|
375 | + WHERE log_namespace = '".$this->pageInfo['page']->getNamespace()."' |
|
376 | 376 | AND log_title = '$title' AND log_timestamp > 1 |
377 | 377 | AND log_type IN ('delete', 'move', 'protect', 'stable')"; |
378 | 378 | $events = $this->conn->query($query)->fetchAll(); |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | $conn = $this->container->get('doctrine')->getManager('replicas')->getConnection(); |
472 | 472 | $res = $conn->query($query)->fetchAll(); |
473 | 473 | |
474 | - $terms = array_map(function ($entry) { |
|
474 | + $terms = array_map(function($entry) { |
|
475 | 475 | return $entry['term']; |
476 | 476 | }, $res); |
477 | 477 | |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | 'prio' => 2, |
483 | 483 | 'name' => 'Wikidata', |
484 | 484 | 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n |
485 | - 'explanation' => "See: <a target='_blank' " . |
|
485 | + 'explanation' => "See: <a target='_blank' ". |
|
486 | 486 | "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>", |
487 | 487 | ]; |
488 | 488 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | 'prio' => 3, |
492 | 492 | 'name' => 'Wikidata', |
493 | 493 | 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n |
494 | - 'explanation' => "See: <a target='_blank' " . |
|
494 | + 'explanation' => "See: <a target='_blank' ". |
|
495 | 495 | "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>", |
496 | 496 | ]; |
497 | 497 | } |
@@ -512,14 +512,14 @@ discard block |
||
512 | 512 | return $rev['length']; |
513 | 513 | } |
514 | 514 | |
515 | - $lastRev = $this->pageHistory[$revIndex - 1]; |
|
515 | + $lastRev = $this->pageHistory[$revIndex-1]; |
|
516 | 516 | |
517 | 517 | // TODO: Remove once T101631 is resolved |
518 | 518 | // Treat as zero change in size if length of previous edit is missing |
519 | 519 | if ($lastRev['length'] === null) { |
520 | 520 | return 0; |
521 | 521 | } else { |
522 | - return $rev['length'] - $lastRev['length']; |
|
522 | + return $rev['length']-$lastRev['length']; |
|
523 | 523 | } |
524 | 524 | } |
525 | 525 | |
@@ -539,10 +539,10 @@ discard block |
||
539 | 539 | |
540 | 540 | // Get UNIX timestamp of the first day of the month of the first edit |
541 | 541 | // This is used as a comparison when building our array of per-month stats |
542 | - $firstEditMonth = mktime(0, 0, 0, (int) $firstEdit->getMonth(), 1, $firstEdit->getYear()); |
|
542 | + $firstEditMonth = mktime(0, 0, 0, (int)$firstEdit->getMonth(), 1, $firstEdit->getYear()); |
|
543 | 543 | |
544 | 544 | $lastEdit = $this->pageInfo['lastEdit']; |
545 | - $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[ $revisionCount - 2 ]; |
|
545 | + $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[$revisionCount-2]; |
|
546 | 546 | |
547 | 547 | // Now we can start our master array. This one will be HUGE! |
548 | 548 | $data = [ |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | // Increment year and month counts for all edits |
614 | 614 | $data['year_count'][$edit->getYear()]['all']++; |
615 | 615 | $data['year_count'][$edit->getYear()]['months'][$edit->getMonth()]['all']++; |
616 | - $data['year_count'][$edit->getYear()]['size'] = (int) $rev['length']; |
|
616 | + $data['year_count'][$edit->getYear()]['size'] = (int)$rev['length']; |
|
617 | 617 | |
618 | 618 | $editsThisMonth = $data['year_count'][$edit->getYear()]['months'][$edit->getMonth()]['all']; |
619 | 619 | if ($editsThisMonth > $data['max_edits_per_month']) { |
@@ -657,9 +657,9 @@ discard block |
||
657 | 657 | } |
658 | 658 | |
659 | 659 | // determine if the next revision was a revert |
660 | - $nextRevision = isset($this->pageHistory[$i + 1]) ? $this->pageHistory[$i + 1] : null; |
|
660 | + $nextRevision = isset($this->pageHistory[$i+1]) ? $this->pageHistory[$i+1] : null; |
|
661 | 661 | $nextRevisionIsRevert = $nextRevision && |
662 | - $this->getDiffSize($i + 1) === -$edit->getSize() && |
|
662 | + $this->getDiffSize($i+1) === -$edit->getSize() && |
|
663 | 663 | $this->aeh->isRevert($nextRevision['comment']); |
664 | 664 | |
665 | 665 | // don't count this edit as content removal if the next edit reverted it |
@@ -7,7 +7,6 @@ |
||
7 | 7 | |
8 | 8 | use AppBundle\Helper\AutomatedEditsHelper; |
9 | 9 | use DateInterval; |
10 | -use DateTime; |
|
11 | 10 | use Mediawiki\Api\SimpleRequest; |
12 | 11 | |
13 | 12 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public function getRevisionCounts(Project $project, User $user) |
28 | 28 | { |
29 | 29 | // Set up cache. |
30 | - $cacheKey = 'revisioncounts.' . $project->getDatabaseName() . '.' . $user->getUsername(); |
|
30 | + $cacheKey = 'revisioncounts.'.$project->getDatabaseName().'.'.$user->getUsername(); |
|
31 | 31 | if ($this->cache->hasItem($cacheKey)) { |
32 | 32 | return $this->cache->getItem($cacheKey)->get(); |
33 | 33 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function getRevisionDates(Project $project, User $user) |
91 | 91 | { |
92 | 92 | // Set up cache. |
93 | - $cacheKey = 'revisiondates.' . $project->getDatabaseName() . '.' . $user->getUsername(); |
|
93 | + $cacheKey = 'revisiondates.'.$project->getDatabaseName().'.'.$user->getUsername(); |
|
94 | 94 | if ($this->cache->hasItem($cacheKey)) { |
95 | 95 | return $this->cache->getItem($cacheKey)->get(); |
96 | 96 | } |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | $results = $resultQuery->fetchAll(); |
163 | 163 | |
164 | 164 | $pageCounts = array_combine( |
165 | - array_map(function ($e) { |
|
165 | + array_map(function($e) { |
|
166 | 166 | return $e['source']; |
167 | 167 | }, $results), |
168 | - array_map(function ($e) { |
|
168 | + array_map(function($e) { |
|
169 | 169 | return $e['value']; |
170 | 170 | }, $results) |
171 | 171 | ); |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | $resultQuery->execute(); |
217 | 217 | $results = $resultQuery->fetchAll(); |
218 | 218 | $logCounts = array_combine( |
219 | - array_map(function ($e) { |
|
219 | + array_map(function($e) { |
|
220 | 220 | return $e['source']; |
221 | 221 | }, $results), |
222 | - array_map(function ($e) { |
|
222 | + array_map(function($e) { |
|
223 | 223 | return $e['value']; |
224 | 224 | }, $results) |
225 | 225 | ); |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | $resultQuery->bindParam(":id", $userId); |
442 | 442 | $resultQuery->execute(); |
443 | 443 | $results = $resultQuery->fetchAll(); |
444 | - $namespaceTotals = array_combine(array_map(function ($e) { |
|
444 | + $namespaceTotals = array_combine(array_map(function($e) { |
|
445 | 445 | return $e['page_namespace']; |
446 | - }, $results), array_map(function ($e) { |
|
446 | + }, $results), array_map(function($e) { |
|
447 | 447 | return $e['total']; |
448 | 448 | }, $results)); |
449 | 449 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | } |
503 | 503 | $queries[] = $sql; |
504 | 504 | } |
505 | - $sql = "(\n" . join("\n) UNION (\n", $queries) . ")\n"; |
|
505 | + $sql = "(\n".join("\n) UNION (\n", $queries).")\n"; |
|
506 | 506 | $resultQuery = $this->getProjectsConnection()->prepare($sql); |
507 | 507 | $resultQuery->bindParam(":username", $username); |
508 | 508 | $resultQuery->execute(); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | protected function getRevisionCounts() |
56 | 56 | { |
57 | - if (! is_array($this->revisionCounts)) { |
|
57 | + if (!is_array($this->revisionCounts)) { |
|
58 | 58 | $this->revisionCounts = $this->getRepository() |
59 | 59 | ->getRevisionCounts($this->project, $this->user); |
60 | 60 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | protected function getRevisionDates() |
69 | 69 | { |
70 | - if (! is_array($this->revisionDates)) { |
|
70 | + if (!is_array($this->revisionDates)) { |
|
71 | 71 | $this->revisionDates = $this->getRepository() |
72 | 72 | ->getRevisionDates($this->project, $this->user); |
73 | 73 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected function getPageCounts() |
82 | 82 | { |
83 | - if (! is_array($this->pageCounts)) { |
|
83 | + if (!is_array($this->pageCounts)) { |
|
84 | 84 | $this->pageCounts = $this->getRepository() |
85 | 85 | ->getPageCounts($this->project, $this->user); |
86 | 86 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | protected function getLogCounts() |
95 | 95 | { |
96 | - if (! is_array($this->logCounts)) { |
|
96 | + if (!is_array($this->logCounts)) { |
|
97 | 97 | $this->logCounts = $this->getRepository() |
98 | 98 | ->getLogCounts($this->project, $this->user); |
99 | 99 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function countAllRevisions() |
144 | 144 | { |
145 | - return $this->countLiveRevisions() + $this->countDeletedRevisions(); |
|
145 | + return $this->countLiveRevisions()+$this->countDeletedRevisions(); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function countRevisionsWithoutComments() |
163 | 163 | { |
164 | - return $this->countAllRevisions() - $this->countRevisionsWithComments(); |
|
164 | + return $this->countAllRevisions()-$this->countRevisionsWithComments(); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function countAllPagesEdited() |
230 | 230 | { |
231 | - return $this->countLivePagesEdited() + $this->countDeletedPagesEdited(); |
|
231 | + return $this->countLivePagesEdited()+$this->countDeletedPagesEdited(); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function countPagesCreated() |
240 | 240 | { |
241 | - return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted(); |
|
241 | + return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted(); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $logCounts = $this->getLogCounts(); |
291 | 291 | $block = isset($logCounts['block-block']) ? (int)$logCounts['block-block'] : 0; |
292 | 292 | $reBlock = isset($logCounts['block-reblock']) ? (int)$logCounts['block-reblock'] : 0; |
293 | - return $block + $reBlock; |
|
293 | + return $block+$reBlock; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0; |
389 | 389 | $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0; |
390 | 390 | $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0; |
391 | - return $import + $interwiki + $upload; |
|
391 | + return $import+$interwiki+$upload; |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -521,9 +521,9 @@ discard block |
||
521 | 521 | public function approvals() |
522 | 522 | { |
523 | 523 | $logCounts = $this->getLogCounts(); |
524 | - $total = $logCounts['review-approve'] + |
|
525 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
526 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
524 | + $total = $logCounts['review-approve']+ |
|
525 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
526 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
527 | 527 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
528 | 528 | return $total; |
529 | 529 | } |
@@ -605,14 +605,14 @@ discard block |
||
605 | 605 | if (!isset($out['totals'][$ns])) { |
606 | 606 | $out['totals'][$ns] = []; |
607 | 607 | } |
608 | - $out['totals'][$ns][$total['year'] . $total['month']] = $total['count']; |
|
608 | + $out['totals'][$ns][$total['year'].$total['month']] = $total['count']; |
|
609 | 609 | } |
610 | 610 | // Fill in the blanks (where no edits were made in a given month for a namespace). |
611 | 611 | for ($y = $out['min_year']; $y <= $out['max_year']; $y++) { |
612 | 612 | for ($m = 1; $m <= 12; $m++) { |
613 | 613 | foreach ($out['totals'] as $nsId => &$total) { |
614 | - if (!isset($total[$y . $m])) { |
|
615 | - $total[$y . $m] = 0; |
|
614 | + if (!isset($total[$y.$m])) { |
|
615 | + $total[$y.$m] = 0; |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | } |
@@ -674,8 +674,8 @@ discard block |
||
674 | 674 | ->globalEditCounts($this->user, $this->project); |
675 | 675 | if ($sorted) { |
676 | 676 | // Sort. |
677 | - uasort($this->globalEditCounts, function ($a, $b) { |
|
678 | - return $b['total'] - $a['total']; |
|
677 | + uasort($this->globalEditCounts, function($a, $b) { |
|
678 | + return $b['total']-$a['total']; |
|
679 | 679 | }); |
680 | 680 | } |
681 | 681 | } |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | $nsName = $project->getNamespaces()[$revision['page_namespace']]; |
714 | 714 | } |
715 | 715 | $page = $project->getRepository() |
716 | - ->getPage($project, $nsName . ':' . $revision['page_title']); |
|
716 | + ->getPage($project, $nsName.':'.$revision['page_title']); |
|
717 | 717 | $edit = new Edit($page, $revision); |
718 | 718 | $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit; |
719 | 719 | } |