@@ -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 | } |