@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | // Create the query we're going to run against the meta database |
| 79 | 79 | $wikiQuery = $this->client->createQueryBuilder(); |
| 80 | 80 | $wikiQuery |
| 81 | - ->select([ 'dbname', 'name', 'url', 'lang' ]) |
|
| 81 | + ->select(['dbname', 'name', 'url', 'lang']) |
|
| 82 | 82 | ->from('wiki') |
| 83 | 83 | ->where($wikiQuery->expr()->eq('dbname', ':project')) |
| 84 | 84 | // The meta database will have the project's URL stored as https://en.wikipedia.org |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | public function allProjects() |
| 130 | 130 | { |
| 131 | 131 | $wikiQuery = $this->client->createQueryBuilder(); |
| 132 | - $wikiQuery->select([ 'dbName', 'name', 'url' ])->from('wiki'); |
|
| 132 | + $wikiQuery->select(['dbName', 'name', 'url'])->from('wiki'); |
|
| 133 | 133 | $stmt = $wikiQuery->execute(); |
| 134 | 134 | $out = $stmt->fetchAll(); |
| 135 | 135 | return $out; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | // as required by Labs. We combine $table with |
| 153 | 153 | // $table_extension in order to generate the new table name |
| 154 | 154 | if ($this->isLabs() && $table_extension !== null) { |
| 155 | - $table = $table . "_" . $table_extension; |
|
| 155 | + $table = $table."_".$table_extension; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Use the table specified in the table mapping configuration, if present. |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | 'username' => $username, |
| 58 | 58 | ]); |
| 59 | 59 | } elseif ($projectQuery != "") { |
| 60 | - return $this->redirectToRoute("PagesProject", [ 'project'=>$projectQuery ]); |
|
| 60 | + return $this->redirectToRoute("PagesProject", ['project'=>$projectQuery]); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // set default wiki so we can populate the namespace selector |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | JOIN $revisionTable ON page_id = rev_page |
| 184 | 184 | $paJoin |
| 185 | 185 | WHERE $whereRev AND rev_parent_id = '0' $namespaceConditionRev $redirectCondition |
| 186 | - " . ($hasPageAssessments ? "GROUP BY rev_page" : "") . " |
|
| 186 | + ".($hasPageAssessments ? "GROUP BY rev_page" : "")." |
|
| 187 | 187 | ) |
| 188 | 188 | |
| 189 | 189 | UNION |
@@ -267,8 +267,8 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | if ($total < 1) { |
| 270 | - $this->addFlash("notice", [ "no-result", $username ]); |
|
| 271 | - return $this->redirectToRoute("PagesProject", [ "project"=>$project ]); |
|
| 270 | + $this->addFlash("notice", ["no-result", $username]); |
|
| 271 | + return $this->redirectToRoute("PagesProject", ["project"=>$project]); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | ksort($pagesByNamespaceByDate); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | public function getRevisionCounts(Project $project, User $user) |
| 19 | 19 | { |
| 20 | 20 | // Set up cache. |
| 21 | - $cacheKey = 'revisioncounts.' . $project->getDatabaseName() . '.' . $user->getUsername(); |
|
| 21 | + $cacheKey = 'revisioncounts.'.$project->getDatabaseName().'.'.$user->getUsername(); |
|
| 22 | 22 | if ($this->cache->hasItem($cacheKey)) { |
| 23 | 23 | return $this->cache->getItem($cacheKey)->get(); |
| 24 | 24 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function getRevisionDates(Project $project, User $user) |
| 80 | 80 | { |
| 81 | 81 | // Set up cache. |
| 82 | - $cacheKey = 'revisiondates.' . $project->getDatabaseName() . '.' . $user->getUsername(); |
|
| 82 | + $cacheKey = 'revisiondates.'.$project->getDatabaseName().'.'.$user->getUsername(); |
|
| 83 | 83 | if ($this->cache->hasItem($cacheKey)) { |
| 84 | 84 | return $this->cache->getItem($cacheKey)->get(); |
| 85 | 85 | } |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | $results = $resultQuery->fetchAll(); |
| 152 | 152 | |
| 153 | 153 | $pageCounts = array_combine( |
| 154 | - array_map(function ($e) { |
|
| 154 | + array_map(function($e) { |
|
| 155 | 155 | return $e['source']; |
| 156 | 156 | }, $results), |
| 157 | - array_map(function ($e) { |
|
| 157 | + array_map(function($e) { |
|
| 158 | 158 | return $e['value']; |
| 159 | 159 | }, $results) |
| 160 | 160 | ); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | // Query. |
| 187 | 187 | $sql = "SELECT CONCAT(log_type, '-', log_action) AS source, COUNT(log_id) AS value |
| 188 | - FROM " . $this->getTableName($project->getDatabaseName(), 'logging') . " |
|
| 188 | + FROM " . $this->getTableName($project->getDatabaseName(), 'logging')." |
|
| 189 | 189 | WHERE log_user = :userId |
| 190 | 190 | GROUP BY log_type, log_action"; |
| 191 | 191 | $resultQuery = $this->getProjectsConnection()->prepare($sql); |
@@ -194,10 +194,10 @@ discard block |
||
| 194 | 194 | $resultQuery->execute(); |
| 195 | 195 | $results = $resultQuery->fetchAll(); |
| 196 | 196 | $logCounts = array_combine( |
| 197 | - array_map(function ($e) { |
|
| 197 | + array_map(function($e) { |
|
| 198 | 198 | return $e['source']; |
| 199 | 199 | }, $results), |
| 200 | - array_map(function ($e) { |
|
| 200 | + array_map(function($e) { |
|
| 201 | 201 | return $e['value']; |
| 202 | 202 | }, $results) |
| 203 | 203 | ); |
@@ -346,9 +346,9 @@ discard block |
||
| 346 | 346 | $resultQuery->bindParam(":id", $userId); |
| 347 | 347 | $resultQuery->execute(); |
| 348 | 348 | $results = $resultQuery->fetchAll(); |
| 349 | - $namespaceTotals = array_combine(array_map(function ($e) { |
|
| 349 | + $namespaceTotals = array_combine(array_map(function($e) { |
|
| 350 | 350 | return $e['page_namespace']; |
| 351 | - }, $results), array_map(function ($e) { |
|
| 351 | + }, $results), array_map(function($e) { |
|
| 352 | 352 | return $e['total']; |
| 353 | 353 | }, $results)); |
| 354 | 354 | return $namespaceTotals; |
@@ -412,14 +412,14 @@ discard block |
||
| 412 | 412 | $revisions = $this->cache->getItem($cacheKey)->get(); |
| 413 | 413 | } else { |
| 414 | 414 | $sql = |
| 415 | - "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, " . |
|
| 416 | - " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, " . |
|
| 417 | - " page_title, page_namespace " . " FROM " . |
|
| 418 | - $this->getTableName($project['dbname'], 'revision') . " JOIN " . |
|
| 419 | - $this->getTableName($project['dbname'], 'page') . |
|
| 420 | - " ON (rev_page = page_id)" . |
|
| 421 | - " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" . |
|
| 422 | - " ORDER BY rev_timestamp DESC" . " LIMIT 10"; |
|
| 415 | + "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, ". |
|
| 416 | + " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, ". |
|
| 417 | + " page_title, page_namespace "." FROM ". |
|
| 418 | + $this->getTableName($project['dbname'], 'revision')." JOIN ". |
|
| 419 | + $this->getTableName($project['dbname'], 'page'). |
|
| 420 | + " ON (rev_page = page_id)". |
|
| 421 | + " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username". |
|
| 422 | + " ORDER BY rev_timestamp DESC"." LIMIT 10"; |
|
| 423 | 423 | $resultQuery = $this->getProjectsConnection()->prepare($sql); |
| 424 | 424 | $resultQuery->bindParam(":username", $username); |
| 425 | 425 | $resultQuery->execute(); |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | if (count($revisions) === 0) { |
| 435 | 435 | continue; |
| 436 | 436 | } |
| 437 | - $revsWithProject = array_map(function (&$item) use ($project) { |
|
| 437 | + $revsWithProject = array_map(function(&$item) use ($project) { |
|
| 438 | 438 | $item['project_name'] = $project['wikiName']; |
| 439 | 439 | $item['project_url'] = $project['url']; |
| 440 | 440 | $item['project_db_name'] = $project['dbName']; |
@@ -444,8 +444,8 @@ discard block |
||
| 444 | 444 | }, $revisions); |
| 445 | 445 | $allRevisions = array_merge($allRevisions, $revsWithProject); |
| 446 | 446 | } |
| 447 | - usort($allRevisions, function ($a, $b) { |
|
| 448 | - return $b['rev_timestamp'] - $a['rev_timestamp']; |
|
| 447 | + usort($allRevisions, function($a, $b) { |
|
| 448 | + return $b['rev_timestamp']-$a['rev_timestamp']; |
|
| 449 | 449 | }); |
| 450 | 450 | |
| 451 | 451 | return array_slice($allRevisions, 0, $topN); |
@@ -467,12 +467,12 @@ discard block |
||
| 467 | 467 | $revisionTable = $this->getTableName($project->getDatabaseName(), 'revision'); |
| 468 | 468 | $pageTable = $this->getTableName($project->getDatabaseName(), 'page'); |
| 469 | 469 | $sql = |
| 470 | - "SELECT " . " YEAR(rev_timestamp) AS `year`," . |
|
| 471 | - " MONTH(rev_timestamp) AS `month`," . " page_namespace," . |
|
| 470 | + "SELECT "." YEAR(rev_timestamp) AS `year`,". |
|
| 471 | + " MONTH(rev_timestamp) AS `month`,"." page_namespace,". |
|
| 472 | 472 | " COUNT(rev_id) AS `count` " |
| 473 | - . " FROM $revisionTable JOIN $pageTable ON (rev_page = page_id)" . |
|
| 474 | - " WHERE rev_user_text = :username" . |
|
| 475 | - " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " . |
|
| 473 | + . " FROM $revisionTable JOIN $pageTable ON (rev_page = page_id)". |
|
| 474 | + " WHERE rev_user_text = :username". |
|
| 475 | + " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace ". |
|
| 476 | 476 | " ORDER BY rev_timestamp DESC"; |
| 477 | 477 | $resultQuery = $this->getProjectsConnection()->prepare($sql); |
| 478 | 478 | $resultQuery->bindParam(":username", $username); |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
| 35 | 35 | |
| 36 | 36 | // Check that a correct namespace value was returned |
| 37 | - $namespaces = (array) json_decode($client->getResponse()->getContent()); |
|
| 37 | + $namespaces = (array)json_decode($client->getResponse()->getContent()); |
|
| 38 | 38 | $this->assertEquals('Utilisateur', array_values($namespaces)[2]); // User in French |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -8,6 +8,6 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | $loader = require __DIR__.'/../vendor/autoload.php'; |
| 10 | 10 | |
| 11 | -AnnotationRegistry::registerLoader([ $loader, 'loadClass' ]); |
|
| 11 | +AnnotationRegistry::registerLoader([$loader, 'loadClass']); |
|
| 12 | 12 | |
| 13 | 13 | return $loader; |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | new AppBundle\AppBundle(), |
| 28 | 28 | ]; |
| 29 | 29 | |
| 30 | - if (in_array($this->getEnvironment(), [ 'dev', 'test' ], true)) { |
|
| 30 | + if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { |
|
| 31 | 31 | $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); |
| 32 | 32 | $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); |
| 33 | 33 | $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); |