@@ -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 getPairData(Project $project, User $user) |
| 28 | 28 | { |
| 29 | 29 | // Set up cache. |
| 30 | - $cacheKey = 'pairdata.' . $project->getDatabaseName() . '.' . $user->getUsername(); |
|
| 30 | + $cacheKey = 'pairdata.'.$project->getDatabaseName().'.'.$user->getUsername(); |
|
| 31 | 31 | if ($this->cache->hasItem($cacheKey)) { |
| 32 | 32 | return $this->cache->getItem($cacheKey)->get(); |
| 33 | 33 | } |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | $resultQuery->execute(); |
| 154 | 154 | $results = $resultQuery->fetchAll(); |
| 155 | 155 | $logCounts = array_combine( |
| 156 | - array_map(function ($e) { |
|
| 156 | + array_map(function($e) { |
|
| 157 | 157 | return $e['source']; |
| 158 | 158 | }, $results), |
| 159 | - array_map(function ($e) { |
|
| 159 | + array_map(function($e) { |
|
| 160 | 160 | return $e['value']; |
| 161 | 161 | }, $results) |
| 162 | 162 | ); |
@@ -378,9 +378,9 @@ discard block |
||
| 378 | 378 | $resultQuery->bindParam(":id", $userId); |
| 379 | 379 | $resultQuery->execute(); |
| 380 | 380 | $results = $resultQuery->fetchAll(); |
| 381 | - $namespaceTotals = array_combine(array_map(function ($e) { |
|
| 381 | + $namespaceTotals = array_combine(array_map(function($e) { |
|
| 382 | 382 | return $e['page_namespace']; |
| 383 | - }, $results), array_map(function ($e) { |
|
| 383 | + }, $results), array_map(function($e) { |
|
| 384 | 384 | return $e['total']; |
| 385 | 385 | }, $results)); |
| 386 | 386 | |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | $queries[] = $sql; |
| 441 | 441 | } |
| 442 | - $sql = "(\n" . join("\n) UNION (\n", $queries) . ")\n"; |
|
| 442 | + $sql = "(\n".join("\n) UNION (\n", $queries).")\n"; |
|
| 443 | 443 | $resultQuery = $this->getProjectsConnection()->prepare($sql); |
| 444 | 444 | $resultQuery->bindParam(":username", $username); |
| 445 | 445 | $resultQuery->execute(); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | protected function getPairData() |
| 56 | 56 | { |
| 57 | - if (! is_array($this->pairData)) { |
|
| 57 | + if (!is_array($this->pairData)) { |
|
| 58 | 58 | $this->pairData = $this->getRepository() |
| 59 | 59 | ->getPairData($this->project, $this->user); |
| 60 | 60 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | protected function getLogCounts() |
| 69 | 69 | { |
| 70 | - if (! is_array($this->logCounts)) { |
|
| 70 | + if (!is_array($this->logCounts)) { |
|
| 71 | 71 | $this->logCounts = $this->getRepository() |
| 72 | 72 | ->getLogCounts($this->project, $this->user); |
| 73 | 73 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function countAllRevisions() |
| 118 | 118 | { |
| 119 | - return $this->countLiveRevisions() + $this->countDeletedRevisions(); |
|
| 119 | + return $this->countLiveRevisions()+$this->countDeletedRevisions(); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function countRevisionsWithoutComments() |
| 137 | 137 | { |
| 138 | - return $this->countAllRevisions() - $this->countRevisionsWithComments(); |
|
| 138 | + return $this->countAllRevisions()-$this->countRevisionsWithComments(); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function countAllPagesEdited() |
| 207 | 207 | { |
| 208 | - return $this->countLivePagesEdited() + $this->countDeletedPagesEdited(); |
|
| 208 | + return $this->countLivePagesEdited()+$this->countDeletedPagesEdited(); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public function countPagesCreated() |
| 217 | 217 | { |
| 218 | - return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted(); |
|
| 218 | + return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted(); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $logCounts = $this->getLogCounts(); |
| 268 | 268 | $block = isset($logCounts['block-block']) ? (int)$logCounts['block-block'] : 0; |
| 269 | 269 | $reBlock = isset($logCounts['block-reblock']) ? (int)$logCounts['block-reblock'] : 0; |
| 270 | - return $block + $reBlock; |
|
| 270 | + return $block+$reBlock; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0; |
| 366 | 366 | $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0; |
| 367 | 367 | $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0; |
| 368 | - return $import + $interwiki + $upload; |
|
| 368 | + return $import+$interwiki+$upload; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -498,9 +498,9 @@ discard block |
||
| 498 | 498 | public function approvals() |
| 499 | 499 | { |
| 500 | 500 | $logCounts = $this->getLogCounts(); |
| 501 | - $total = $logCounts['review-approve'] + |
|
| 502 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
| 503 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
| 501 | + $total = $logCounts['review-approve']+ |
|
| 502 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
| 503 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
| 504 | 504 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
| 505 | 505 | return $total; |
| 506 | 506 | } |
@@ -582,14 +582,14 @@ discard block |
||
| 582 | 582 | if (!isset($out['totals'][$ns])) { |
| 583 | 583 | $out['totals'][$ns] = []; |
| 584 | 584 | } |
| 585 | - $out['totals'][$ns][$total['year'] . $total['month']] = $total['count']; |
|
| 585 | + $out['totals'][$ns][$total['year'].$total['month']] = $total['count']; |
|
| 586 | 586 | } |
| 587 | 587 | // Fill in the blanks (where no edits were made in a given month for a namespace). |
| 588 | 588 | for ($y = $out['min_year']; $y <= $out['max_year']; $y++) { |
| 589 | 589 | for ($m = 1; $m <= 12; $m++) { |
| 590 | 590 | foreach ($out['totals'] as $nsId => &$total) { |
| 591 | - if (!isset($total[$y . $m])) { |
|
| 592 | - $total[$y . $m] = 0; |
|
| 591 | + if (!isset($total[$y.$m])) { |
|
| 592 | + $total[$y.$m] = 0; |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | } |
@@ -651,8 +651,8 @@ discard block |
||
| 651 | 651 | ->globalEditCounts($this->user, $this->project); |
| 652 | 652 | if ($sorted) { |
| 653 | 653 | // Sort. |
| 654 | - uasort($this->globalEditCounts, function ($a, $b) { |
|
| 655 | - return $b['total'] - $a['total']; |
|
| 654 | + uasort($this->globalEditCounts, function($a, $b) { |
|
| 655 | + return $b['total']-$a['total']; |
|
| 656 | 656 | }); |
| 657 | 657 | } |
| 658 | 658 | } |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | $nsName = $project->getNamespaces()[$revision['page_namespace']]; |
| 691 | 691 | } |
| 692 | 692 | $page = $project->getRepository() |
| 693 | - ->getPage($project, $nsName . ':' . $revision['page_title']); |
|
| 693 | + ->getPage($project, $nsName.':'.$revision['page_title']); |
|
| 694 | 694 | $edit = new Edit($page, $revision); |
| 695 | 695 | $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit; |
| 696 | 696 | } |