@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | 'username' => $username, |
79 | 79 | ]); |
80 | 80 | } elseif ($projectQuery != "") { |
81 | - return $this->redirectToRoute("PagesProject", [ 'project'=>$projectQuery ]); |
|
81 | + return $this->redirectToRoute("PagesProject", ['project'=>$projectQuery]); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | // set default wiki so we can populate the namespace selector |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | if ($total < 1) { |
210 | - $this->addFlash('notice', [ 'no-result', $username ]); |
|
211 | - return $this->redirectToRoute('PagesProject', [ 'project' => $project ]); |
|
210 | + $this->addFlash('notice', ['no-result', $username]); |
|
211 | + return $this->redirectToRoute('PagesProject', ['project' => $project]); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | ksort($pagesByNamespaceByDate); |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | $resultQuery->execute(); |
147 | 147 | $results = $resultQuery->fetchAll(); |
148 | 148 | $logCounts = array_combine( |
149 | - array_map(function ($e) { |
|
149 | + array_map(function($e) { |
|
150 | 150 | return $e['source']; |
151 | 151 | }, $results), |
152 | - array_map(function ($e) { |
|
152 | + array_map(function($e) { |
|
153 | 153 | return $e['value']; |
154 | 154 | }, $results) |
155 | 155 | ); |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | $resultQuery->bindParam(":id", $userId); |
367 | 367 | $resultQuery->execute(); |
368 | 368 | $results = $resultQuery->fetchAll(); |
369 | - $namespaceTotals = array_combine(array_map(function ($e) { |
|
369 | + $namespaceTotals = array_combine(array_map(function($e) { |
|
370 | 370 | return $e['page_namespace']; |
371 | - }, $results), array_map(function ($e) { |
|
371 | + }, $results), array_map(function($e) { |
|
372 | 372 | return $e['total']; |
373 | 373 | }, $results)); |
374 | 374 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | } |
428 | 428 | $queries[] = $sql; |
429 | 429 | } |
430 | - $sql = "(\n" . join("\n) UNION (\n", $queries) . ")\n"; |
|
430 | + $sql = "(\n".join("\n) UNION (\n", $queries).")\n"; |
|
431 | 431 | $resultQuery = $this->getProjectsConnection()->prepare($sql); |
432 | 432 | $resultQuery->bindParam(":username", $username); |
433 | 433 | $resultQuery->execute(); |
@@ -6,7 +6,6 @@ |
||
6 | 6 | namespace Xtools; |
7 | 7 | |
8 | 8 | use DateInterval; |
9 | -use DateTime; |
|
10 | 9 | use Mediawiki\Api\SimpleRequest; |
11 | 10 | |
12 | 11 | /** |
@@ -11,7 +11,6 @@ |
||
11 | 11 | use Symfony\Component\HttpFoundation\Request; |
12 | 12 | use Symfony\Component\HttpFoundation\Response; |
13 | 13 | use Xtools\ProjectRepository; |
14 | -use Xtools\User; |
|
15 | 14 | use Xtools\UserRepository; |
16 | 15 | |
17 | 16 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | 'xtSubtitle' => 'tool-autoedits-desc', |
87 | 87 | 'xtPage' => 'autoedits', |
88 | 88 | 'project' => $project, |
89 | - 'namespace' => (int) $namespace, |
|
89 | + 'namespace' => (int)$namespace, |
|
90 | 90 | 'start' => $startDate, |
91 | 91 | 'end' => $endDate, |
92 | 92 | ]); |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | // Get individual counts of how many times each tool was used. |
158 | 158 | // This also includes a wikilink to the tool. |
159 | 159 | $toolCounts = $user->getAutomatedCounts($projectData, $namespace, $start, $end); |
160 | - $toolsTotal = array_reduce($toolCounts, function ($a, $b) { |
|
161 | - return $a + $b['count']; |
|
160 | + $toolsTotal = array_reduce($toolCounts, function($a, $b) { |
|
161 | + return $a+$b['count']; |
|
162 | 162 | }); |
163 | 163 | |
164 | 164 | // Query to get combined (semi)automated using for all edits |
@@ -10,7 +10,6 @@ |
||
10 | 10 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
11 | 11 | use Symfony\Component\HttpFoundation\Request; |
12 | 12 | use Symfony\Component\HttpFoundation\Response; |
13 | -use Psr\Cache\CacheItemPoolInterface; |
|
14 | 13 | use Xtools\Project; |
15 | 14 | use Xtools\ProjectRepository; |
16 | 15 | use Xtools\User; |
@@ -102,7 +102,7 @@ |
||
102 | 102 | * |
103 | 103 | * @param string $project The project domain name. |
104 | 104 | * @param string $username The username. |
105 | - * @param string $namespace Namespace ID or 'all' for all namespaces. |
|
105 | + * @param integer $namespace Namespace ID or 'all' for all namespaces. |
|
106 | 106 | * |
107 | 107 | * @Route("/editsummary/{project}/{username}/{namespace}", name="EditSummaryResult") |
108 | 108 | * |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | 'xtSubtitle' => 'tool-es-desc', |
93 | 93 | 'xtPage' => 'es', |
94 | 94 | 'project' => $theProject, |
95 | - 'namespace' => (int) $namespace, |
|
95 | + 'namespace' => (int)$namespace, |
|
96 | 96 | ] |
97 | 97 | ); |
98 | 98 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | { |
159 | 159 | $dbName = $project->getDatabaseName(); |
160 | 160 | |
161 | - $cacheKey = 'editsummaryusage.' . $dbName . '.' |
|
162 | - . $user->getCacheKey() . '.' . $namespace; |
|
161 | + $cacheKey = 'editsummaryusage.'.$dbName.'.' |
|
162 | + . $user->getCacheKey().'.'.$namespace; |
|
163 | 163 | |
164 | 164 | $cache = $this->container->get('cache.app'); |
165 | 165 | if ($cache->hasItem($cacheKey)) { |
@@ -246,8 +246,7 @@ discard block |
||
246 | 246 | if ($row['rev_minor_edit'] == 0) { |
247 | 247 | if ($row['rev_comment'] !== '') { |
248 | 248 | isset($monthEditsummaryTotals[$monthkey]) ? |
249 | - $monthEditsummaryTotals[$monthkey]++ : |
|
250 | - $monthEditsummaryTotals[$monthkey] = 1; |
|
249 | + $monthEditsummaryTotals[$monthkey]++ : $monthEditsummaryTotals[$monthkey] = 1; |
|
251 | 250 | $totalSummariesMajor++; |
252 | 251 | } |
253 | 252 | |
@@ -264,8 +263,7 @@ discard block |
||
264 | 263 | // If there is a comment, count it |
265 | 264 | if ($row['rev_comment'] !== '') { |
266 | 265 | isset($monthEditsummaryTotals[$monthkey]) ? |
267 | - $monthEditsummaryTotals[$monthkey]++ : |
|
268 | - $monthEditsummaryTotals[$monthkey] = 1; |
|
266 | + $monthEditsummaryTotals[$monthkey]++ : $monthEditsummaryTotals[$monthkey] = 1; |
|
269 | 267 | $totalSummariesMinor++; |
270 | 268 | $totalEditsMinor++; |
271 | 269 | } else { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function isAutomated($summary, $projectDomain) |
59 | 59 | { |
60 | - return (bool) $this->getTool($summary, $projectDomain); |
|
60 | + return (bool)$this->getTool($summary, $projectDomain); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | |
110 | 110 | $revertEntries = array_filter( |
111 | 111 | $this->getTools($projectDomain), |
112 | - function ($tool) { |
|
112 | + function($tool) { |
|
113 | 113 | return isset($tool['revert']); |
114 | 114 | } |
115 | 115 | ); |
116 | 116 | |
117 | 117 | // If 'revert' is set to `true`, the use 'regex' as the regular expression, |
118 | 118 | // otherwise 'revert' is assumed to be the regex string. |
119 | - $this->revertTools[$projectDomain] = array_map(function ($revertTool) { |
|
119 | + $this->revertTools[$projectDomain] = array_map(function($revertTool) { |
|
120 | 120 | return [ |
121 | 121 | 'link' => $revertTool['link'], |
122 | 122 | 'regex' => $revertTool['revert'] === true ? $revertTool['regex'] : $revertTool['revert'] |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $this->page = $page; |
50 | 50 | |
51 | 51 | // Copy over supported attributes |
52 | - $this->id = (int) $attrs['id']; |
|
52 | + $this->id = (int)$attrs['id']; |
|
53 | 53 | |
54 | 54 | // Allow DateTime or string (latter assumed to be of format YmdHis) |
55 | 55 | if ($attrs['timestamp'] instanceof DateTime) { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $isSection = preg_match_all("/^\/\* (.*?) \*\//", $summary, $sectionMatch); |
199 | 199 | |
200 | 200 | if ($isSection) { |
201 | - $pageUrl = $this->getProject()->getUrl(false) . str_replace( |
|
201 | + $pageUrl = $this->getProject()->getUrl(false).str_replace( |
|
202 | 202 | '$1', |
203 | 203 | $this->getPage()->getTitle(), |
204 | 204 | $this->getProject()->getArticlePath() |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | // Must have underscores for the link to properly go to the section |
209 | 209 | $sectionTitleLink = htmlspecialchars(str_replace(' ', '_', $sectionTitle)); |
210 | 210 | |
211 | - $sectionWikitext = "<a target='_blank' href='$pageUrl#$sectionTitleLink'>→</a>" . |
|
212 | - "<em class='text-muted'>" . htmlspecialchars($sectionTitle) . ":</em> "; |
|
211 | + $sectionWikitext = "<a target='_blank' href='$pageUrl#$sectionTitleLink'>→</a>". |
|
212 | + "<em class='text-muted'>".htmlspecialchars($sectionTitle).":</em> "; |
|
213 | 213 | $summary = str_replace($sectionMatch[0][0], $sectionWikitext, $summary); |
214 | 214 | } |
215 | 215 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | ); |
224 | 224 | |
225 | 225 | // Use normalized page title (underscored, capitalized) |
226 | - $pageUrl = $this->getProject()->getUrl(false) . str_replace( |
|
226 | + $pageUrl = $this->getProject()->getUrl(false).str_replace( |
|
227 | 227 | '$1', |
228 | 228 | ucfirst(str_replace(' ', '_', $wikiLinkPath)), |
229 | 229 | $this->getProject()->getArticlePath() |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | public function getDiffUrl() |
262 | 262 | { |
263 | 263 | $project = $this->getProject(); |
264 | - $path = str_replace('$1', 'Special:Diff/' . $this->id, $project->getArticlePath()); |
|
265 | - return rtrim($project->getUrl(), '/') . $path; |
|
264 | + $path = str_replace('$1', 'Special:Diff/'.$this->id, $project->getArticlePath()); |
|
265 | + return rtrim($project->getUrl(), '/').$path; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | public function getPermaUrl() |
273 | 273 | { |
274 | 274 | $project = $this->getProject(); |
275 | - $path = str_replace('$1', 'Special:PermaLink/' . $this->id, $project->getArticlePath()); |
|
276 | - return rtrim($project->getUrl(), '/') . $path; |
|
275 | + $path = str_replace('$1', 'Special:PermaLink/'.$this->id, $project->getArticlePath()); |
|
276 | + return rtrim($project->getUrl(), '/').$path; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public function isAutomated(Container $container) |
307 | 307 | { |
308 | - return (bool) $this->getTool($container); |
|
308 | + return (bool)$this->getTool($container); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -3,8 +3,6 @@ |
||
3 | 3 | namespace AppBundle\Controller; |
4 | 4 | |
5 | 5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
6 | -use Symfony\Component\CssSelector\Exception\InternalErrorException; |
|
7 | -use Symfony\Component\Debug\Exception\ContextErrorException; |
|
8 | 6 | use Symfony\Component\HttpFoundation\Request; |
9 | 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
10 | 8 | use Xtools\ProjectRepository; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $username = $request->query->get('username'); |
49 | 49 | |
50 | 50 | if ($projectQuery != '' && $username != '') { |
51 | - $routeParams = [ 'project' => $projectQuery, 'username' => $username ]; |
|
51 | + $routeParams = ['project' => $projectQuery, 'username' => $username]; |
|
52 | 52 | return $this->redirectToRoute( |
53 | 53 | 'rfxvoteResult', |
54 | 54 | $routeParams |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | $titles = []; |
168 | 168 | |
169 | 169 | while ($row = $sth->fetch()) { |
170 | - $titles[] = $namespaces[$row['page_namespace']] . |
|
171 | - ':' .$row['page_title']; |
|
170 | + $titles[] = $namespaces[$row['page_namespace']]. |
|
171 | + ':'.$row['page_title']; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Chunking... it's possible to make a URI too long |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @Route("/rfxvote/index.php", name="rfxvoteIndexPhp") |
40 | 40 | * @Route("/rfxvote", name="RfXVoteCalculator") |
41 | 41 | * |
42 | - * @return Response |
|
42 | + * @return \Symfony\Component\HttpFoundation\Response |
|
43 | 43 | */ |
44 | 44 | public function indexAction() |
45 | 45 | { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @Route("/rfxvote/{project}/{username}", name="rfxvoteResult") |
90 | 90 | * |
91 | - * @return Response |
|
91 | + * @return \Symfony\Component\HttpFoundation\Response |
|
92 | 92 | */ |
93 | 93 | public function resultAction($project, $username) |
94 | 94 | { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $this->stopwatch->start($cacheKey, 'XTools'); |
80 | 80 | $api = $this->getMediawikiApi($project); |
81 | - $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
81 | + $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"]; |
|
82 | 82 | $query = new SimpleRequest('query', $params); |
83 | 83 | $result = []; |
84 | 84 | $res = $api->getRequest($query); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | // Create the API query. |
115 | 115 | $api = $this->getMediawikiApi($project); |
116 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
116 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
117 | 117 | $query = new SimpleRequest('query', $params); |
118 | 118 | |
119 | 119 | // Get the result. |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | { |
158 | 158 | $username = $user->getUsername(); |
159 | 159 | |
160 | - $cacheKey = 'pages.' . $project->getDatabaseName() . '.' |
|
161 | - . $user->getCacheKey() . '.' . $namespace . '.' . $redirects; |
|
160 | + $cacheKey = 'pages.'.$project->getDatabaseName().'.' |
|
161 | + . $user->getCacheKey().'.'.$namespace.'.'.$redirects; |
|
162 | 162 | if ($this->cache->hasItem($cacheKey)) { |
163 | 163 | return $this->cache->getItem($cacheKey)->get(); |
164 | 164 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | JOIN $revisionTable ON page_id = rev_page |
217 | 217 | $paJoin |
218 | 218 | WHERE $whereRev AND rev_parent_id = '0' $namespaceConditionRev $redirectCondition |
219 | - " . ($hasPageAssessments ? 'GROUP BY rev_page' : '') . " |
|
219 | + ".($hasPageAssessments ? 'GROUP BY rev_page' : '')." |
|
220 | 220 | ) |
221 | 221 | |
222 | 222 | UNION |
@@ -263,21 +263,21 @@ discard block |
||
263 | 263 | */ |
264 | 264 | public function countEdits(Project $project, User $user, $namespace = 'all', $start = '', $end = '') |
265 | 265 | { |
266 | - $cacheKey = 'editcount.' . $project->getDatabaseName() . '.' |
|
267 | - . $user->getCacheKey() . '.' . $namespace; |
|
266 | + $cacheKey = 'editcount.'.$project->getDatabaseName().'.' |
|
267 | + . $user->getCacheKey().'.'.$namespace; |
|
268 | 268 | |
269 | 269 | $condBegin = ''; |
270 | 270 | $condEnd = ''; |
271 | 271 | |
272 | 272 | if (!empty($start)) { |
273 | - $cacheKey .= '.' . $start; |
|
273 | + $cacheKey .= '.'.$start; |
|
274 | 274 | |
275 | 275 | // For the query |
276 | 276 | $start = date('Ymd000000', strtotime($start)); |
277 | 277 | $condBegin = 'AND rev_timestamp >= :start '; |
278 | 278 | } |
279 | 279 | if (!empty($end)) { |
280 | - $cacheKey .= '.' . $end; |
|
280 | + $cacheKey .= '.'.$end; |
|
281 | 281 | |
282 | 282 | // For the query |
283 | 283 | $end = date('Ymd235959', strtotime($end)); |
@@ -337,21 +337,21 @@ discard block |
||
337 | 337 | */ |
338 | 338 | public function countAutomatedEdits(Project $project, User $user, $namespace = 'all', $start = '', $end = '') |
339 | 339 | { |
340 | - $cacheKey = 'autoeditcount.' . $project->getDatabaseName() . '.' |
|
341 | - . $user->getCacheKey() . '.' . $namespace; |
|
340 | + $cacheKey = 'autoeditcount.'.$project->getDatabaseName().'.' |
|
341 | + . $user->getCacheKey().'.'.$namespace; |
|
342 | 342 | |
343 | 343 | $condBegin = ''; |
344 | 344 | $condEnd = ''; |
345 | 345 | |
346 | 346 | if (!empty($start)) { |
347 | - $cacheKey .= '.' . $start; |
|
347 | + $cacheKey .= '.'.$start; |
|
348 | 348 | |
349 | 349 | // For the query |
350 | 350 | $start = date('Ymd000000', strtotime($start)); |
351 | 351 | $condBegin = 'AND rev_timestamp >= :start '; |
352 | 352 | } |
353 | 353 | if (!empty($end)) { |
354 | - $cacheKey .= '.' . $end; |
|
354 | + $cacheKey .= '.'.$end; |
|
355 | 355 | |
356 | 356 | // For the query |
357 | 357 | $end = date('Ymd235959', strtotime($end)); |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | $tagJoin = $tags != '' ? "LEFT OUTER JOIN $tagTable ON ct_rev_id = rev_id" : ''; |
384 | 384 | $condTools[] = "ct_tag IN ($tags)"; |
385 | 385 | } |
386 | - $condTool = 'AND (' . implode(' OR ', $condTools) . ')'; |
|
386 | + $condTool = 'AND ('.implode(' OR ', $condTools).')'; |
|
387 | 387 | |
388 | 388 | $sql = "SELECT COUNT(DISTINCT(rev_id)) |
389 | 389 | FROM $revisionTable |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | $resultQuery->bindParam('namespace', $namespace); |
409 | 409 | } |
410 | 410 | $resultQuery->execute(); |
411 | - $result = (int) $resultQuery->fetchColumn(); |
|
411 | + $result = (int)$resultQuery->fetchColumn(); |
|
412 | 412 | |
413 | 413 | // Cache for 10 minutes, and return. |
414 | 414 | $cacheItem = $this->cache->getItem($cacheKey) |
@@ -440,21 +440,21 @@ discard block |
||
440 | 440 | $end = '', |
441 | 441 | $offset = 0 |
442 | 442 | ) { |
443 | - $cacheKey = 'nonautoedits.' . $project->getDatabaseName() . '.' |
|
444 | - . $user->getCacheKey() . '.' . $namespace . '.' . $offset; |
|
443 | + $cacheKey = 'nonautoedits.'.$project->getDatabaseName().'.' |
|
444 | + . $user->getCacheKey().'.'.$namespace.'.'.$offset; |
|
445 | 445 | |
446 | 446 | $condBegin = ''; |
447 | 447 | $condEnd = ''; |
448 | 448 | |
449 | 449 | if (!empty($start)) { |
450 | - $cacheKey .= '.' . $start; |
|
450 | + $cacheKey .= '.'.$start; |
|
451 | 451 | |
452 | 452 | // For the query |
453 | 453 | $start = date('Ymd000000', strtotime($start)); |
454 | 454 | $condBegin = 'AND revs.rev_timestamp >= :start '; |
455 | 455 | } |
456 | 456 | if (!empty($end)) { |
457 | - $cacheKey .= '.' . $end; |
|
457 | + $cacheKey .= '.'.$end; |
|
458 | 458 | |
459 | 459 | // For the query |
460 | 460 | $end = date('Ymd235959', strtotime($end)); |
@@ -547,21 +547,21 @@ discard block |
||
547 | 547 | $start = '', |
548 | 548 | $end = '' |
549 | 549 | ) { |
550 | - $cacheKey = 'autotoolcounts.' . $project->getDatabaseName() . '.' |
|
551 | - . $user->getCacheKey() . '.' . $namespace; |
|
550 | + $cacheKey = 'autotoolcounts.'.$project->getDatabaseName().'.' |
|
551 | + . $user->getCacheKey().'.'.$namespace; |
|
552 | 552 | |
553 | 553 | $condBegin = ''; |
554 | 554 | $condEnd = ''; |
555 | 555 | |
556 | 556 | if (!empty($start)) { |
557 | - $cacheKey .= '.' . $start; |
|
557 | + $cacheKey .= '.'.$start; |
|
558 | 558 | |
559 | 559 | // For the query |
560 | 560 | $start = date('Ymd000000', strtotime($start)); |
561 | 561 | $condBegin = 'AND rev_timestamp >= :start '; |
562 | 562 | } |
563 | 563 | if (!empty($end)) { |
564 | - $cacheKey .= '.' . $end; |
|
564 | + $cacheKey .= '.'.$end; |
|
565 | 565 | |
566 | 566 | // For the query |
567 | 567 | $end = date('Ymd235959', strtotime($end)); |
@@ -608,13 +608,13 @@ discard block |
||
608 | 608 | if ($condTool === '') { |
609 | 609 | $condTool = "ct_tag = $tag"; |
610 | 610 | } else { |
611 | - $condTool = '(' . $condTool . " OR ct_tag = $tag)"; |
|
611 | + $condTool = '('.$condTool." OR ct_tag = $tag)"; |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
615 | 615 | // Developer error, no regex or tag provided for this tool. |
616 | 616 | if ($condTool === '') { |
617 | - throw new Exception("No regex or tag found for the tool $toolname. " . |
|
617 | + throw new Exception("No regex or tag found for the tool $toolname. ". |
|
618 | 618 | "Please verify this entry in semi_automated.yml"); |
619 | 619 | } |
620 | 620 | |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | } |
667 | 667 | |
668 | 668 | // Sort the array by count |
669 | - uasort($results, function ($a, $b) { |
|
670 | - return $b['count'] - $a['count']; |
|
669 | + uasort($results, function($a, $b) { |
|
670 | + return $b['count']-$a['count']; |
|
671 | 671 | }); |
672 | 672 | |
673 | 673 | // Cache for 10 minutes, and return. |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * Get the user's (system) edit count. |
97 | 97 | * @param string $databaseName The database to query. |
98 | 98 | * @param string $username The username to find. |
99 | - * @return int|null As returned by the database. |
|
99 | + * @return string|boolean As returned by the database. |
|
100 | 100 | */ |
101 | 101 | public function getEditCount($databaseName, $username) |
102 | 102 | { |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | * Get the combined regex and tags for all semi-automated tools, |
742 | 742 | * ready to be used in a query. |
743 | 743 | * @param string $projectDomain Such as en.wikipedia.org |
744 | - * @param $conn Doctrine\DBAL\Connection Used for proper escaping |
|
744 | + * @param \Doctrine\DBAL\Connection $conn Doctrine\DBAL\Connection Used for proper escaping |
|
745 | 745 | * @return string[] In the format: |
746 | 746 | * ['combined|regex', 'combined,tags'] |
747 | 747 | */ |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | |
474 | 474 | /** |
475 | 475 | * Get the date and time of the user's first edit. |
476 | - * @return DateTime|bool The time of the first revision, or false. |
|
476 | + * @return DateInterval The time of the first revision, or false. |
|
477 | 477 | */ |
478 | 478 | public function datetimeFirstRevision() |
479 | 479 | { |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | |
484 | 484 | /** |
485 | 485 | * Get the date and time of the user's first edit. |
486 | - * @return DateTime|bool The time of the last revision, or false. |
|
486 | + * @return DateInterval The time of the last revision, or false. |
|
487 | 487 | */ |
488 | 488 | public function datetimeLastRevision() |
489 | 489 | { |
@@ -6,7 +6,6 @@ |
||
6 | 6 | namespace Xtools; |
7 | 7 | |
8 | 8 | use DateTime; |
9 | -use Exception; |
|
10 | 9 | use DatePeriod; |
11 | 10 | use DateInterval; |
12 | 11 | use GuzzleHttp; |
@@ -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 | ]; |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | $out['totals'][$ns][$total['year']] = []; |
804 | 804 | } |
805 | 805 | |
806 | - $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count']; |
|
806 | + $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count']; |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | $dateRange = new DatePeriod( |
@@ -813,8 +813,8 @@ discard block |
||
813 | 813 | ); |
814 | 814 | |
815 | 815 | foreach ($dateRange as $monthObj) { |
816 | - $year = (int) $monthObj->format('Y'); |
|
817 | - $month = (int) $monthObj->format('n'); |
|
816 | + $year = (int)$monthObj->format('Y'); |
|
817 | + $month = (int)$monthObj->format('n'); |
|
818 | 818 | |
819 | 819 | // Fill in labels |
820 | 820 | $out['monthLabels'][] = $monthObj->format('Y-m'); |
@@ -930,8 +930,8 @@ discard block |
||
930 | 930 | |
931 | 931 | if ($sorted) { |
932 | 932 | // Sort. |
933 | - uasort($this->globalEditCounts, function ($a, $b) { |
|
934 | - return $b['total'] - $a['total']; |
|
933 | + uasort($this->globalEditCounts, function($a, $b) { |
|
934 | + return $b['total']-$a['total']; |
|
935 | 935 | }); |
936 | 936 | } |
937 | 937 | |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | $nsName = $project->getNamespaces()[$revision['page_namespace']]; |
968 | 968 | } |
969 | 969 | $page = $project->getRepository() |
970 | - ->getPage($project, $nsName . ':' . $revision['page_title']); |
|
970 | + ->getPage($project, $nsName.':'.$revision['page_title']); |
|
971 | 971 | $edit = new Edit($page, $revision); |
972 | 972 | $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit; |
973 | 973 | } |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | public function countSmallEdits() |
1009 | 1009 | { |
1010 | 1010 | $editSizeData = $this->getEditSizeData(); |
1011 | - return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0; |
|
1011 | + return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0; |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | /** |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | public function countLargeEdits() |
1019 | 1019 | { |
1020 | 1020 | $editSizeData = $this->getEditSizeData(); |
1021 | - return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0; |
|
1021 | + return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0; |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | /** |