@@ -5,9 +5,7 @@ |
||
| 5 | 5 | |
| 6 | 6 | namespace AppBundle\Helper; |
| 7 | 7 | |
| 8 | -use DateTime; |
|
| 9 | 8 | use Symfony\Component\DependencyInjection\ContainerInterface; |
| 10 | -use Xtools\ProjectRepository; |
|
| 11 | 9 | |
| 12 | 10 | /** |
| 13 | 11 | * Helper class for getting information about semi-automated edits. |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | $this->stopwatch->start($cacheKey, 'XTools'); |
| 79 | 79 | $api = $this->getMediawikiApi($project); |
| 80 | - $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
| 80 | + $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"]; |
|
| 81 | 81 | $query = new SimpleRequest('query', $params); |
| 82 | 82 | $result = []; |
| 83 | 83 | $res = $api->getRequest($query); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | // Create the API query. |
| 114 | 114 | $api = $this->getMediawikiApi($project); |
| 115 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
| 115 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
| 116 | 116 | $query = new SimpleRequest('query', $params); |
| 117 | 117 | |
| 118 | 118 | // Get the result. |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | { |
| 157 | 157 | $username = $user->getUsername(); |
| 158 | 158 | |
| 159 | - $cacheKey = 'pages.' . $project->getDatabaseName() . '.' |
|
| 160 | - . $user->getCacheKey() . '.' . $namespace . '.' . $redirects; |
|
| 159 | + $cacheKey = 'pages.'.$project->getDatabaseName().'.' |
|
| 160 | + . $user->getCacheKey().'.'.$namespace.'.'.$redirects; |
|
| 161 | 161 | if ($this->cache->hasItem($cacheKey)) { |
| 162 | 162 | return $this->cache->getItem($cacheKey)->get(); |
| 163 | 163 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | JOIN $revisionTable ON page_id = rev_page |
| 216 | 216 | $paJoin |
| 217 | 217 | WHERE $whereRev AND rev_parent_id = '0' $namespaceConditionRev $redirectCondition |
| 218 | - " . ($hasPageAssessments ? 'GROUP BY rev_page' : '') . " |
|
| 218 | + ".($hasPageAssessments ? 'GROUP BY rev_page' : '')." |
|
| 219 | 219 | ) |
| 220 | 220 | |
| 221 | 221 | UNION |
@@ -262,21 +262,21 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | public function countEdits(Project $project, User $user, $namespace = 'all', $start = '', $end = '') |
| 264 | 264 | { |
| 265 | - $cacheKey = 'editcount.' . $project->getDatabaseName() . '.' |
|
| 266 | - . $user->getCacheKey() . '.' . $namespace; |
|
| 265 | + $cacheKey = 'editcount.'.$project->getDatabaseName().'.' |
|
| 266 | + . $user->getCacheKey().'.'.$namespace; |
|
| 267 | 267 | |
| 268 | 268 | $condBegin = ''; |
| 269 | 269 | $condEnd = ''; |
| 270 | 270 | |
| 271 | 271 | if (!empty($start)) { |
| 272 | - $cacheKey .= '.' . $start; |
|
| 272 | + $cacheKey .= '.'.$start; |
|
| 273 | 273 | |
| 274 | 274 | // For the query |
| 275 | 275 | $start = date('Ymd000000', strtotime($start)); |
| 276 | 276 | $condBegin = 'AND rev_timestamp >= :start '; |
| 277 | 277 | } |
| 278 | 278 | if (!empty($end)) { |
| 279 | - $cacheKey .= '.' . $end; |
|
| 279 | + $cacheKey .= '.'.$end; |
|
| 280 | 280 | |
| 281 | 281 | // For the query |
| 282 | 282 | $end = date('Ymd235959', strtotime($end)); |
@@ -335,21 +335,21 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | public function countAutomatedEdits(Project $project, User $user, $namespace = 'all', $start = '', $end = '') |
| 337 | 337 | { |
| 338 | - $cacheKey = 'autoeditcount.' . $project->getDatabaseName() . '.' |
|
| 339 | - . $user->getCacheKey() . '.' . $namespace; |
|
| 338 | + $cacheKey = 'autoeditcount.'.$project->getDatabaseName().'.' |
|
| 339 | + . $user->getCacheKey().'.'.$namespace; |
|
| 340 | 340 | |
| 341 | 341 | $condBegin = ''; |
| 342 | 342 | $condEnd = ''; |
| 343 | 343 | |
| 344 | 344 | if (!empty($start)) { |
| 345 | - $cacheKey .= '.' . $start; |
|
| 345 | + $cacheKey .= '.'.$start; |
|
| 346 | 346 | |
| 347 | 347 | // For the query |
| 348 | 348 | $start = date('Ymd000000', strtotime($start)); |
| 349 | 349 | $condBegin = 'AND rev_timestamp >= :start '; |
| 350 | 350 | } |
| 351 | 351 | if (!empty($end)) { |
| 352 | - $cacheKey .= '.' . $end; |
|
| 352 | + $cacheKey .= '.'.$end; |
|
| 353 | 353 | |
| 354 | 354 | // For the query |
| 355 | 355 | $end = date('Ymd235959', strtotime($end)); |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | $conn = $this->getProjectsConnection(); |
| 365 | 365 | $tools = $this->container->getParameter('automated_tools'); |
| 366 | - $toolRegexes = array_map(function ($tool) { |
|
| 366 | + $toolRegexes = array_map(function($tool) { |
|
| 367 | 367 | return $tool['regex']; |
| 368 | 368 | }, $tools); |
| 369 | 369 | $regex = $conn->quote(implode('|', $toolRegexes), \PDO::PARAM_STR); |
@@ -425,21 +425,21 @@ discard block |
||
| 425 | 425 | $end = '', |
| 426 | 426 | $offset = 0 |
| 427 | 427 | ) { |
| 428 | - $cacheKey = 'nonautoedits.' . $project->getDatabaseName() . '.' |
|
| 429 | - . $user->getCacheKey() . '.' . $namespace . '.' . $offset; |
|
| 428 | + $cacheKey = 'nonautoedits.'.$project->getDatabaseName().'.' |
|
| 429 | + . $user->getCacheKey().'.'.$namespace.'.'.$offset; |
|
| 430 | 430 | |
| 431 | 431 | $condBegin = ''; |
| 432 | 432 | $condEnd = ''; |
| 433 | 433 | |
| 434 | 434 | if (!empty($start)) { |
| 435 | - $cacheKey .= '.' . $start; |
|
| 435 | + $cacheKey .= '.'.$start; |
|
| 436 | 436 | |
| 437 | 437 | // For the query |
| 438 | 438 | $start = date('Ymd000000', strtotime($start)); |
| 439 | 439 | $condBegin = 'AND revs.rev_timestamp >= :start '; |
| 440 | 440 | } |
| 441 | 441 | if (!empty($end)) { |
| 442 | - $cacheKey .= '.' . $end; |
|
| 442 | + $cacheKey .= '.'.$end; |
|
| 443 | 443 | |
| 444 | 444 | // For the query |
| 445 | 445 | $end = date('Ymd235959', strtotime($end)); |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | |
| 456 | 456 | // Build regex for all semi-automated tools |
| 457 | 457 | $tools = $this->container->getParameter('automated_tools'); |
| 458 | - $toolRegexes = array_map(function ($tool) { |
|
| 458 | + $toolRegexes = array_map(function($tool) { |
|
| 459 | 459 | return $tool['regex']; |
| 460 | 460 | }, $tools); |
| 461 | 461 | $regex = $conn->quote(implode('|', $toolRegexes), \PDO::PARAM_STR); |
@@ -532,21 +532,21 @@ discard block |
||
| 532 | 532 | $start = '', |
| 533 | 533 | $end = '' |
| 534 | 534 | ) { |
| 535 | - $cacheKey = 'autotoolcounts.' . $project->getDatabaseName() . '.' |
|
| 536 | - . $user->getCacheKey() . '.' . $namespace; |
|
| 535 | + $cacheKey = 'autotoolcounts.'.$project->getDatabaseName().'.' |
|
| 536 | + . $user->getCacheKey().'.'.$namespace; |
|
| 537 | 537 | |
| 538 | 538 | $condBegin = ''; |
| 539 | 539 | $condEnd = ''; |
| 540 | 540 | |
| 541 | 541 | if (!empty($start)) { |
| 542 | - $cacheKey .= '.' . $start; |
|
| 542 | + $cacheKey .= '.'.$start; |
|
| 543 | 543 | |
| 544 | 544 | // For the query |
| 545 | 545 | $start = date('Ymd000000', strtotime($start)); |
| 546 | 546 | $condBegin = 'AND rev_timestamp >= :start '; |
| 547 | 547 | } |
| 548 | 548 | if (!empty($end)) { |
| 549 | - $cacheKey .= '.' . $end; |
|
| 549 | + $cacheKey .= '.'.$end; |
|
| 550 | 550 | |
| 551 | 551 | // For the query |
| 552 | 552 | $end = date('Ymd235959', strtotime($end)); |
@@ -624,8 +624,8 @@ discard block |
||
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | // Sort the array by count |
| 627 | - uasort($results, function ($a, $b) { |
|
| 628 | - return $b['count'] - $a['count']; |
|
| 627 | + uasort($results, function($a, $b) { |
|
| 628 | + return $b['count']-$a['count']; |
|
| 629 | 629 | }); |
| 630 | 630 | |
| 631 | 631 | // Cache for 10 minutes, and return. |
@@ -206,21 +206,21 @@ |
||
| 206 | 206 | |
| 207 | 207 | $namespaces = $project->getNamespaces(); |
| 208 | 208 | |
| 209 | - return array_map(function ($rev) use ($namespaces) { |
|
| 209 | + return array_map(function($rev) use ($namespaces) { |
|
| 210 | 210 | $pageTitle = $rev['page_title']; |
| 211 | 211 | |
| 212 | 212 | if ($rev['page_namespace'] !== '0') { |
| 213 | - $pageTitle = $namespaces[$rev['page_namespace']] . ":$pageTitle"; |
|
| 213 | + $pageTitle = $namespaces[$rev['page_namespace']].":$pageTitle"; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | return [ |
| 217 | 217 | 'page_title' => $pageTitle, |
| 218 | - 'page_namespace' => (int) $rev['page_namespace'], |
|
| 219 | - 'rev_id' => (int) $rev['rev_id'], |
|
| 218 | + 'page_namespace' => (int)$rev['page_namespace'], |
|
| 219 | + 'rev_id' => (int)$rev['rev_id'], |
|
| 220 | 220 | 'timestamp' => DateTime::createFromFormat('YmdHis', $rev['timestamp']), |
| 221 | - 'minor' => (bool) $rev['minor'], |
|
| 222 | - 'length' => (int) $rev['length'], |
|
| 223 | - 'length_change' => (int) $rev['length_change'], |
|
| 221 | + 'minor' => (bool)$rev['minor'], |
|
| 222 | + 'length' => (int)$rev['length'], |
|
| 223 | + 'length_change' => (int)$rev['length_change'], |
|
| 224 | 224 | 'comment' => $rev['comment'], |
| 225 | 225 | ]; |
| 226 | 226 | }, $revs); |
@@ -5,18 +5,13 @@ |
||
| 5 | 5 | |
| 6 | 6 | namespace AppBundle\Controller; |
| 7 | 7 | |
| 8 | -use Exception; |
|
| 9 | -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
|
| 10 | 8 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 11 | -use Symfony\Component\HttpFoundation\Request; |
|
| 12 | 9 | use Symfony\Component\HttpFoundation\Response; |
| 13 | -use Symfony\Component\Debug\Exception\FatalErrorException; |
|
| 14 | 10 | use FOS\RestBundle\Controller\Annotations as Rest; |
| 15 | 11 | use FOS\RestBundle\Controller\FOSRestController; |
| 16 | 12 | use FOS\RestBundle\View\View; |
| 17 | 13 | use Xtools\ProjectRepository; |
| 18 | 14 | use Xtools\UserRepository; |
| 19 | -use Xtools\Page; |
|
| 20 | 15 | use Xtools\Edit; |
| 21 | 16 | |
| 22 | 17 | /** |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | $data = $user->getNonautomatedEdits($project, $namespace, $start, $end, $offset); |
| 106 | 106 | |
| 107 | 107 | if ($format === 'html') { |
| 108 | - $edits = array_map(function ($attrs) use ($project, $username) { |
|
| 108 | + $edits = array_map(function($attrs) use ($project, $username) { |
|
| 109 | 109 | $nsName = ''; |
| 110 | 110 | if ($attrs['page_namespace']) { |
| 111 | 111 | $nsName = $project->getNamespaces()[$attrs['page_namespace']]; |
| 112 | 112 | } |
| 113 | 113 | $page = $project->getRepository() |
| 114 | - ->getPage($project, $nsName . ':' . $attrs['page_title']); |
|
| 114 | + ->getPage($project, $nsName.':'.$attrs['page_title']); |
|
| 115 | 115 | $attrs['id'] = $attrs['rev_id']; |
| 116 | 116 | $attrs['username'] = $username; |
| 117 | 117 | return new Edit($page, $attrs); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $conn = $this->getDoctrine()->getManager('default')->getConnection(); |
| 163 | - $date = date('Y-m-d'); |
|
| 163 | + $date = date('Y-m-d'); |
|
| 164 | 164 | |
| 165 | 165 | // Increment count in timeline |
| 166 | 166 | $existsSql = "SELECT 1 FROM usage_timeline |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
| 15 | 15 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 16 | 16 | use Symfony\Component\HttpFoundation\Request; |
| 17 | -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
| 18 | 17 | use Xtools\ProjectRepository; |
| 19 | 18 | use Xtools\RFA; |
| 20 | 19 | |
@@ -172,7 +172,7 @@ |
||
| 172 | 172 | $end = $rfa->get_enddate(); |
| 173 | 173 | |
| 174 | 174 | $percent = (sizeof($support) / |
| 175 | - (sizeof($support) + sizeof($oppose) + sizeof($neutral))); |
|
| 175 | + (sizeof($support)+sizeof($oppose)+sizeof($neutral))); |
|
| 176 | 176 | |
| 177 | 177 | $percent = $percent * 100; |
| 178 | 178 | |
@@ -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; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $username = $request->query->get('username'); |
| 42 | 42 | |
| 43 | 43 | if ($projectQuery != "" && $username != "") { |
| 44 | - $routeParams = [ 'project'=>$projectQuery, 'username' => $username ]; |
|
| 44 | + $routeParams = ['project'=>$projectQuery, 'username' => $username]; |
|
| 45 | 45 | return $this->redirectToRoute( |
| 46 | 46 | "rfapResult", |
| 47 | 47 | $routeParams |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | $titles = []; |
| 136 | 136 | |
| 137 | 137 | while ($row = $sth->fetch()) { |
| 138 | - $titles[] = $namespaces[$row["page_namespace"]] . |
|
| 139 | - ":" .$row["page_title"]; |
|
| 138 | + $titles[] = $namespaces[$row["page_namespace"]]. |
|
| 139 | + ":".$row["page_title"]; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | // Chunking... it's possible to make a URI too long |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * Returns matches. |
| 21 | 21 | * |
| 22 | 22 | * @param $input |
| 23 | - * @param $matches |
|
| 23 | + * @param string[] $matches |
|
| 24 | 24 | * |
| 25 | 25 | * @return int |
| 26 | 26 | */ |
@@ -85,6 +85,9 @@ discard block |
||
| 85 | 85 | return $this->userSectionFound; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | + /** |
|
| 89 | + * @param string $sectionName |
|
| 90 | + */ |
|
| 88 | 91 | public function getSection($sectionName) { |
| 89 | 92 | $sectionName = strtolower($sectionName); |
| 90 | 93 | if (!isset($this->data[$sectionName])) { |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @return int |
| 26 | 26 | */ |
| 27 | - protected function findSig( $input, &$matches ) { |
|
| 27 | + protected function findSig($input, &$matches) { |
|
| 28 | 28 | //Supports User: and User talk: wikilinks, {{fullurl}}, unsubsted {{unsigned}}, unsubsted {{unsigned2}}, anything that looks like a custom sig template |
| 29 | 29 | // TODO: Cross-wiki this sucker |
| 30 | 30 | return preg_match_all( |
@@ -89,8 +89,7 @@ |
||
| 89 | 89 | $sectionName = strtolower($sectionName); |
| 90 | 90 | if (!isset($this->data[$sectionName])) { |
| 91 | 91 | return []; |
| 92 | - } |
|
| 93 | - else { |
|
| 92 | + } else { |
|
| 94 | 93 | return $this->data[$sectionName]; |
| 95 | 94 | } |
| 96 | 95 | } |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | ]); |
| 62 | 62 | |
| 63 | 63 | $this->assertEquals( |
| 64 | - "<script>alert("XSS baby")</script> " . |
|
| 64 | + "<script>alert("XSS baby")</script> ". |
|
| 65 | 65 | "<a target='_blank' href='/wiki/Test_page'>test page</a>", |
| 66 | 66 | $edit->getWikifiedSummary() |
| 67 | 67 | ); |