@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | $promises[] = $promise; |
118 | 118 | |
119 | 119 | // Handle response of $promise asynchronously. |
120 | - $promise->then(function ($response) use ($key, $endpoint) { |
|
121 | - $result = (array) json_decode($response->getBody()->getContents()); |
|
120 | + $promise->then(function($response) use ($key, $endpoint) { |
|
121 | + $result = (array)json_decode($response->getBody()->getContents()); |
|
122 | 122 | |
123 | 123 | $this->getRepository() |
124 | 124 | ->getLog() |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | // We'll log this to see how often it happens. |
136 | 136 | $this->getRepository() |
137 | 137 | ->getLog() |
138 | - ->error("Failed to fetch data for $endpoint via async, " . |
|
138 | + ->error("Failed to fetch data for $endpoint via async, ". |
|
139 | 139 | "re-attempting synchoronously."); |
140 | 140 | } |
141 | 141 | }); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | // Filter out unblocks unless requested. |
193 | 193 | if ($blocksOnly) { |
194 | - $blocks = array_filter($blocks, function ($block) { |
|
194 | + $blocks = array_filter($blocks, function($block) { |
|
195 | 195 | return $block['log_action'] === 'block'; |
196 | 196 | }); |
197 | 197 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function countAllRevisions() |
227 | 227 | { |
228 | - return $this->countLiveRevisions() + $this->countDeletedRevisions(); |
|
228 | + return $this->countLiveRevisions()+$this->countDeletedRevisions(); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function countRevisionsWithoutComments() |
246 | 246 | { |
247 | - return $this->countLiveRevisions() - $this->countRevisionsWithComments(); |
|
247 | + return $this->countLiveRevisions()-$this->countRevisionsWithComments(); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public function countAllPagesEdited() |
285 | 285 | { |
286 | - return $this->countLivePagesEdited() + $this->countDeletedPagesEdited(); |
|
286 | + return $this->countLivePagesEdited()+$this->countDeletedPagesEdited(); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public function countPagesCreated() |
295 | 295 | { |
296 | - return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted(); |
|
296 | + return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted(); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | } elseif ($block['log_action'] === 'unblock') { |
434 | 434 | // The last block was lifted. So the duration will be the time from when the |
435 | 435 | // last block was set to the time of the unblock. |
436 | - $timeSinceLastBlock = $timestamp - $lastBlock[0]; |
|
436 | + $timeSinceLastBlock = $timestamp-$lastBlock[0]; |
|
437 | 437 | if ($timeSinceLastBlock > $this->longestBlockSeconds) { |
438 | 438 | $this->longestBlockSeconds = $timeSinceLastBlock; |
439 | 439 | |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | // The last block was modified. So we will adjust $lastBlock to include |
445 | 445 | // the difference of the duration of the new reblock, and time since the last block. |
446 | 446 | // $lastBlock is left unchanged if its duration was indefinite. |
447 | - $timeSinceLastBlock = $timestamp - $lastBlock[0]; |
|
448 | - $lastBlock[1] = $timeSinceLastBlock + $duration; |
|
447 | + $timeSinceLastBlock = $timestamp-$lastBlock[0]; |
|
448 | + $lastBlock[1] = $timeSinceLastBlock+$duration; |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | } |
456 | 456 | |
457 | 457 | // Test if the last block is still active, and if so use the expiry as the duration. |
458 | - $lastBlockExpiry = $lastBlock[0] + $lastBlock[1]; |
|
458 | + $lastBlockExpiry = $lastBlock[0]+$lastBlock[1]; |
|
459 | 459 | if ($lastBlockExpiry > time() && $lastBlockExpiry > $this->longestBlockSeconds) { |
460 | 460 | $this->longestBlockSeconds = $lastBlock[1]; |
461 | 461 | // Otherwise, test if the duration of the last block is now the longest overall. |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | // If invalid, $duration is left as null. |
497 | 497 | if (strtotime($durationStr)) { |
498 | 498 | $expiry = strtotime($durationStr, $timestamp); |
499 | - $duration = $expiry - $timestamp; |
|
499 | + $duration = $expiry-$timestamp; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | return [$timestamp, $duration]; |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0; |
574 | 574 | $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0; |
575 | 575 | $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0; |
576 | - return $import + $interwiki + $upload; |
|
576 | + return $import+$interwiki+$upload; |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
@@ -697,9 +697,9 @@ discard block |
||
697 | 697 | public function approvals() |
698 | 698 | { |
699 | 699 | $logCounts = $this->getLogCounts(); |
700 | - $total = $logCounts['review-approve'] + |
|
701 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
702 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
700 | + $total = $logCounts['review-approve']+ |
|
701 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
702 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
703 | 703 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
704 | 704 | return $total; |
705 | 705 | } |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | $logCounts = $this->getLogCounts(); |
724 | 724 | $create2 = $logCounts['newusers-create2'] ?: 0; |
725 | 725 | $byemail = $logCounts['newusers-byemail'] ?: 0; |
726 | - return $create2 + $byemail; |
|
726 | + return $create2+$byemail; |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | |
776 | 776 | $totals = $this->getRepository()->getMonthCounts($this->project, $this->user); |
777 | 777 | $out = [ |
778 | - 'yearLabels' => [], // labels for years |
|
778 | + 'yearLabels' => [], // labels for years |
|
779 | 779 | 'monthLabels' => [], // labels for months |
780 | 780 | 'totals' => [], // actual totals, grouped by namespace, year and then month |
781 | 781 | ]; |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | $out['totals'][$ns][$total['year']] = []; |
843 | 843 | } |
844 | 844 | |
845 | - $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count']; |
|
845 | + $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count']; |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | return [$out, $firstEdit]; |
@@ -859,8 +859,8 @@ discard block |
||
859 | 859 | private function fillInMonthTotalsAndLabels($out, DatePeriod $dateRange) |
860 | 860 | { |
861 | 861 | foreach ($dateRange as $monthObj) { |
862 | - $year = (int) $monthObj->format('Y'); |
|
863 | - $month = (int) $monthObj->format('n'); |
|
862 | + $year = (int)$monthObj->format('Y'); |
|
863 | + $month = (int)$monthObj->format('n'); |
|
864 | 864 | |
865 | 865 | // Fill in labels |
866 | 866 | $out['monthLabels'][] = $monthObj->format('Y-m'); |
@@ -963,8 +963,8 @@ discard block |
||
963 | 963 | |
964 | 964 | if ($sorted) { |
965 | 965 | // Sort. |
966 | - uasort($this->globalEditCounts, function ($a, $b) { |
|
967 | - return $b['total'] - $a['total']; |
|
966 | + uasort($this->globalEditCounts, function($a, $b) { |
|
967 | + return $b['total']-$a['total']; |
|
968 | 968 | }); |
969 | 969 | } |
970 | 970 | |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | $nsName = $project->getNamespaces()[$revision['page_namespace']]; |
1001 | 1001 | } |
1002 | 1002 | $page = $project->getRepository() |
1003 | - ->getPage($project, $nsName . ':' . $revision['page_title']); |
|
1003 | + ->getPage($project, $nsName.':'.$revision['page_title']); |
|
1004 | 1004 | $edit = new Edit($page, $revision); |
1005 | 1005 | $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit; |
1006 | 1006 | } |
@@ -1041,7 +1041,7 @@ discard block |
||
1041 | 1041 | public function countSmallEdits() |
1042 | 1042 | { |
1043 | 1043 | $editSizeData = $this->getEditSizeData(); |
1044 | - return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0; |
|
1044 | + return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0; |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | /** |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | public function countLargeEdits() |
1052 | 1052 | { |
1053 | 1053 | $editSizeData = $this->getEditSizeData(); |
1054 | - return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0; |
|
1054 | + return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0; |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | public function loginAction() |
90 | 90 | { |
91 | 91 | try { |
92 | - list( $next, $token ) = $this->getOauthClient()->initiate(); |
|
92 | + list($next, $token) = $this->getOauthClient()->initiate(); |
|
93 | 93 | } catch (Exception $oauthException) { |
94 | 94 | throw $oauthException; |
95 | 95 | // @TODO Make this work. |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | . '?title=Special:OAuth'; |
157 | 157 | $conf = new ClientConfig($endpoint); |
158 | 158 | $consumerKey = $this->getParameter('oauth_key'); |
159 | - $consumerSecret = $this->getParameter('oauth_secret'); |
|
159 | + $consumerSecret = $this->getParameter('oauth_secret'); |
|
160 | 160 | $conf->setConsumer(new Consumer($consumerKey, $consumerSecret)); |
161 | 161 | $this->oauthClient = new Client($conf); |
162 | 162 | // Callback URL is hardcoded in the consumer registration. |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $normalized = []; |
77 | 77 | if (isset($result['query']['normalized'])) { |
78 | 78 | array_map( |
79 | - function ($e) use (&$normalized) { |
|
79 | + function($e) use (&$normalized) { |
|
80 | 80 | $normalized[$e['to']] = $e['from']; |
81 | 81 | }, |
82 | 82 | $result['query']['normalized'] |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
162 | 162 | $innerPromise = $this->api->getRequestAsync($query); |
163 | 163 | |
164 | - $innerPromise->then(function ($result) use (&$data) { |
|
164 | + $innerPromise->then(function($result) use (&$data) { |
|
165 | 165 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
166 | 166 | if (isset($result['error']) || !isset($result['query'])) { |
167 | 167 | return $data['promise']->resolve($data); |
@@ -90,20 +90,20 @@ discard block |
||
90 | 90 | |
91 | 91 | // MULTIPLIERS (to review) |
92 | 92 | $multipliers = [ |
93 | - 'account-age-mult' => 1.25, # 0 if = 365 jours |
|
94 | - 'edit-count-mult' => 1.25, # 0 if = 10 000 |
|
95 | - 'user-page-mult' => 0.1, # 0 if = |
|
96 | - 'patrols-mult' => 1, # 0 if = |
|
97 | - 'blocks-mult' => 1.4, # 0 if = 10 |
|
93 | + 'account-age-mult' => 1.25, # 0 if = 365 jours |
|
94 | + 'edit-count-mult' => 1.25, # 0 if = 10 000 |
|
95 | + 'user-page-mult' => 0.1, # 0 if = |
|
96 | + 'patrols-mult' => 1, # 0 if = |
|
97 | + 'blocks-mult' => 1.4, # 0 if = 10 |
|
98 | 98 | 'afd-mult' => 1.15, |
99 | - 'recent-activity-mult' => 0.9, # 0 if = |
|
99 | + 'recent-activity-mult' => 0.9, # 0 if = |
|
100 | 100 | 'aiv-mult' => 1.15, |
101 | - 'edit-summaries-mult' => 0.8, # 0 if = |
|
102 | - 'namespaces-mult' => 1.0, # 0 if = |
|
103 | - 'pages-created-live-mult' => 1.4, # 0 if = |
|
104 | - 'pages-created-deleted-mult' => 1.4, # 0 if = |
|
105 | - 'rpp-mult' => 1.15, # 0 if = |
|
106 | - 'user-rights-mult' => 0.75, # 0 if = |
|
101 | + 'edit-summaries-mult' => 0.8, # 0 if = |
|
102 | + 'namespaces-mult' => 1.0, # 0 if = |
|
103 | + 'pages-created-live-mult' => 1.4, # 0 if = |
|
104 | + 'pages-created-deleted-mult' => 1.4, # 0 if = |
|
105 | + 'rpp-mult' => 1.15, # 0 if = |
|
106 | + 'user-rights-mult' => 0.75, # 0 if = |
|
107 | 107 | ]; |
108 | 108 | |
109 | 109 | // Grab the connection to the replica database (which is separate from the above) |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | $now = new DateTime(); |
186 | 186 | $date = new DateTime($value); |
187 | 187 | $diff = $date->diff($now); |
188 | - $formula = 365 * $diff->format('%y') + 30 * $diff->format('%m') + $diff->format('%d'); |
|
189 | - $value = $formula - 365; |
|
188 | + $formula = 365 * $diff->format('%y')+30 * $diff->format('%m')+$diff->format('%d'); |
|
189 | + $value = $formula-365; |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | - $multiplierKey = $row['source'] . '-mult'; |
|
194 | + $multiplierKey = $row['source'].'-mult'; |
|
195 | 195 | $multiplier = isset($multipliers[$multiplierKey]) ? $multipliers[$multiplierKey] : 1; |
196 | 196 | $score = max(min($value * $multiplier, 100), -100); |
197 | 197 | $master[$key]['mult'] = $multiplier; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function countAutomatedEdits() |
44 | 44 | { |
45 | - return (int) $this->getRepository()->countAutomatedEdits( |
|
45 | + return (int)$this->getRepository()->countAutomatedEdits( |
|
46 | 46 | $this->project, |
47 | 47 | $this->user, |
48 | 48 | $this->namespace, |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | |
71 | 71 | $namespaces = $this->project->getNamespaces(); |
72 | 72 | |
73 | - return array_map(function ($rev) use ($namespaces) { |
|
73 | + return array_map(function($rev) use ($namespaces) { |
|
74 | 74 | $pageTitle = $rev['page_title']; |
75 | 75 | $fullPageTitle = ''; |
76 | 76 | |
77 | 77 | if ($rev['page_namespace'] !== '0') { |
78 | - $fullPageTitle = $namespaces[$rev['page_namespace']] . ":$pageTitle"; |
|
78 | + $fullPageTitle = $namespaces[$rev['page_namespace']].":$pageTitle"; |
|
79 | 79 | } else { |
80 | 80 | $fullPageTitle = $pageTitle; |
81 | 81 | } |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | return [ |
84 | 84 | 'full_page_title' => $fullPageTitle, |
85 | 85 | 'page_title' => $pageTitle, |
86 | - 'page_namespace' => (int) $rev['page_namespace'], |
|
87 | - 'rev_id' => (int) $rev['rev_id'], |
|
86 | + 'page_namespace' => (int)$rev['page_namespace'], |
|
87 | + 'rev_id' => (int)$rev['rev_id'], |
|
88 | 88 | 'timestamp' => DateTime::createFromFormat('YmdHis', $rev['timestamp']), |
89 | - 'minor' => (bool) $rev['minor'], |
|
90 | - 'length' => (int) $rev['length'], |
|
91 | - 'length_change' => (int) $rev['length_change'], |
|
89 | + 'minor' => (bool)$rev['minor'], |
|
90 | + 'length' => (int)$rev['length'], |
|
91 | + 'length_change' => (int)$rev['length_change'], |
|
92 | 92 | 'comment' => $rev['comment'], |
93 | 93 | ]; |
94 | 94 | }, $revs); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | return $this->editCounts[$domain]; |
94 | 94 | } |
95 | 95 | |
96 | - $this->editCounts[$domain] = (int) $this->getRepository()->getEditCount( |
|
96 | + $this->editCounts[$domain] = (int)$this->getRepository()->getEditCount( |
|
97 | 97 | $project->getDatabaseName(), |
98 | 98 | $this->getUsername() |
99 | 99 | ); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function isAnon() |
161 | 161 | { |
162 | - return (bool) filter_var($this->username, FILTER_VALIDATE_IP); |
|
162 | + return (bool)filter_var($this->username, FILTER_VALIDATE_IP); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public function countEdits(Project $project, $namespace = 'all', $start = '', $end = '') |
223 | 223 | { |
224 | - return (int) $this->getRepository()->countEdits($project, $this, $namespace, $start, $end); |
|
224 | + return (int)$this->getRepository()->countEdits($project, $this, $namespace, $start, $end); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | // Get individual counts of how many times each tool was used. |
127 | 127 | // This also includes a wikilink to the tool. |
128 | 128 | $toolCounts = $autoEdits->getAutomatedCounts(); |
129 | - $toolsTotal = array_reduce($toolCounts, function ($a, $b) { |
|
130 | - return $a + $b['count']; |
|
129 | + $toolsTotal = array_reduce($toolCounts, function($a, $b) { |
|
130 | + return $a+$b['count']; |
|
131 | 131 | }); |
132 | 132 | |
133 | 133 | // Query to get combined (semi)automated using for all edits |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $res['automated_editcount'] = $autoEdits->countAutomatedEdits(); |
204 | 204 | } |
205 | 205 | |
206 | - $res['nonautomated_editcount'] = $res['total_editcount'] - $res['automated_editcount']; |
|
206 | + $res['nonautomated_editcount'] = $res['total_editcount']-$res['automated_editcount']; |
|
207 | 207 | |
208 | 208 | $response->setData($res); |
209 | 209 | return $response; |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | if ($request->query->get('format') !== 'html') { |
244 | 244 | return new JsonResponse( |
245 | 245 | [ |
246 | - 'error' => 'Unable to show any data. User has made over ' . |
|
247 | - $user->maxEdits() . ' edits.', |
|
246 | + 'error' => 'Unable to show any data. User has made over '. |
|
247 | + $user->maxEdits().' edits.', |
|
248 | 248 | ], |
249 | 249 | Response::HTTP_FORBIDDEN |
250 | 250 | ); |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | |
263 | 263 | if ($request->query->get('format') === 'html') { |
264 | 264 | if ($edits) { |
265 | - $edits = array_map(function ($attrs) use ($project, $user) { |
|
265 | + $edits = array_map(function($attrs) use ($project, $user) { |
|
266 | 266 | $page = $project->getRepository() |
267 | 267 | ->getPage($project, $attrs['full_page_title']); |
268 | 268 | $pageTitles[] = $attrs['full_page_title']; |
@@ -232,7 +232,7 @@ |
||
232 | 232 | ]; |
233 | 233 | |
234 | 234 | if ($pages->getNumResults() === $pages->resultsPerPage()) { |
235 | - $ret['continue'] = $offset + 1; |
|
235 | + $ret['continue'] = $offset+1; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | $ret['pages'] = $pagesList; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $params = $this->convertLegacyParams($params); |
39 | 39 | |
40 | 40 | // Remove blank values. |
41 | - return array_filter($params, function ($param) { |
|
41 | + return array_filter($params, function($param) { |
|
42 | 42 | // 'namespace' or 'username' could be '0'. |
43 | 43 | return $param !== null && $param !== ''; |
44 | 44 | }); |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $conn = $this->container->get('doctrine') |
331 | 331 | ->getManager('default') |
332 | 332 | ->getConnection(); |
333 | - $date = date('Y-m-d'); |
|
333 | + $date = date('Y-m-d'); |
|
334 | 334 | |
335 | 335 | // Increment count in timeline |
336 | 336 | $existsSql = "SELECT 1 FROM usage_api_timeline |