@@ -12,7 +12,7 @@ |
||
| 12 | 12 | // Feel free to remove this, extend it, or make something more sophisticated. |
| 13 | 13 | if (isset($_SERVER['HTTP_CLIENT_IP']) |
| 14 | 14 | || isset($_SERVER['HTTP_X_FORWARDED_FOR']) |
| 15 | - || !( in_array(@$_SERVER['REMOTE_ADDR'], [ '127.0.0.1', 'fe80::1', '::1' ]) || php_sapi_name() === 'cli-server' ) |
|
| 15 | + || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server') |
|
| 16 | 16 | ) { |
| 17 | 17 | header('HTTP/1.0 403 Forbidden'); |
| 18 | 18 | exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.'); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | 'quote/all.html.twig', |
| 112 | 112 | [ |
| 113 | 113 | 'base_dir' => realpath( |
| 114 | - $this->getParameter('kernel.root_dir') . '/..' |
|
| 114 | + $this->getParameter('kernel.root_dir').'/..' |
|
| 115 | 115 | ), |
| 116 | 116 | 'xtPage' => 'bash', |
| 117 | 117 | 'quotes' => $quotes, |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | 'quote/view.html.twig', |
| 161 | 161 | [ |
| 162 | 162 | 'base_dir' => realpath( |
| 163 | - $this->getParameter('kernel.root_dir') . '/..' |
|
| 163 | + $this->getParameter('kernel.root_dir').'/..' |
|
| 164 | 164 | ), |
| 165 | 165 | "xtPage" => "bash", |
| 166 | 166 | "text" => $text, |
@@ -251,9 +251,9 @@ |
||
| 251 | 251 | $conn = $this->getProjectsConnection(); |
| 252 | 252 | $pageTable = $this->getTableName($project->getDatabaseName(), 'page'); |
| 253 | 253 | $query = "SELECT page_id " |
| 254 | - . " FROM $pageTable " |
|
| 255 | - . " WHERE page_namespace = :ns AND page_title = :title AND page_len > 0 " |
|
| 256 | - . " LIMIT 1"; |
|
| 254 | + . " FROM $pageTable " |
|
| 255 | + . " WHERE page_namespace = :ns AND page_title = :title AND page_len > 0 " |
|
| 256 | + . " LIMIT 1"; |
|
| 257 | 257 | $params = [ |
| 258 | 258 | 'ns' => $namespaceId, |
| 259 | 259 | 'title' => $pageTitle, |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | || $projMetadata['url'] == "https://$project" |
| 149 | 149 | || $projMetadata['url'] == "https://$project.org" |
| 150 | 150 | || $projMetadata['url'] == "https://www.$project") { |
| 151 | - $this->log->debug(__METHOD__ . " Using cached data for $project"); |
|
| 151 | + $this->log->debug(__METHOD__." Using cached data for $project"); |
|
| 152 | 152 | return $projMetadata; |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // Redis cache |
| 207 | - $cacheKey = "projectMetadata." . preg_replace("/[^A-Za-z0-9]/", '', $projectUrl); |
|
| 207 | + $cacheKey = "projectMetadata.".preg_replace("/[^A-Za-z0-9]/", '', $projectUrl); |
|
| 208 | 208 | if ($this->cache->hasItem($cacheKey)) { |
| 209 | 209 | $this->metadata = $this->cache->getItem($cacheKey)->get(); |
| 210 | 210 | return $this->metadata; |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $optedIn = $this->container->getParameter('opted_in'); |
| 285 | 285 | // In case there's just one given. |
| 286 | 286 | if (!is_array($optedIn)) { |
| 287 | - $optedIn = [ $optedIn ]; |
|
| 287 | + $optedIn = [$optedIn]; |
|
| 288 | 288 | } |
| 289 | 289 | return $optedIn; |
| 290 | 290 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | public function loginAction() |
| 91 | 91 | { |
| 92 | 92 | try { |
| 93 | - list( $next, $token ) = $this->getOauthClient()->initiate(); |
|
| 93 | + list($next, $token) = $this->getOauthClient()->initiate(); |
|
| 94 | 94 | } catch (Exception $oauthException) { |
| 95 | 95 | throw $oauthException; |
| 96 | 96 | // @TODO Make this work. |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | . '/index.php?title=Special:OAuth'; |
| 156 | 156 | $conf = new ClientConfig($endpoint); |
| 157 | 157 | $consumerKey = $this->getParameter('oauth_key'); |
| 158 | - $consumerSecret = $this->getParameter('oauth_secret'); |
|
| 158 | + $consumerSecret = $this->getParameter('oauth_secret'); |
|
| 159 | 159 | $conf->setConsumer(new Consumer($consumerKey, $consumerSecret)); |
| 160 | 160 | $this->oauthClient = new Client($conf); |
| 161 | 161 | // Callback URL is hardcoded in the consumer registration. |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | namespace Xtools; |
| 7 | 7 | |
| 8 | 8 | use Mediawiki\Api\MediawikiApi; |
| 9 | -use Symfony\Component\VarDumper\VarDumper; |
|
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * A Project is a single wiki that XTools is querying. |
@@ -200,7 +200,7 @@ |
||
| 200 | 200 | /** |
| 201 | 201 | * Get an array of this project's namespaces and their IDs. |
| 202 | 202 | * |
| 203 | - * @return string[] Keys are IDs, values are names. |
|
| 203 | + * @return string Keys are IDs, values are names. |
|
| 204 | 204 | */ |
| 205 | 205 | public function getNamespaces() |
| 206 | 206 | { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function getUrl($withTrailingSlash = true) |
| 119 | 119 | { |
| 120 | - return rtrim($this->getBasicInfo()['url'], '/') . ($withTrailingSlash ? '/' : ''); |
|
| 120 | + return rtrim($this->getBasicInfo()['url'], '/').($withTrailingSlash ? '/' : ''); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | $metadata = $this->getMetadata(); |
| 175 | 175 | return isset($metadata['general']['script']) |
| 176 | 176 | ? $metadata['general']['script'] |
| 177 | - : $this->getScriptPath() . '/index.php'; |
|
| 177 | + : $this->getScriptPath().'/index.php'; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function getApiUrl() |
| 186 | 186 | { |
| 187 | - return rtrim($this->getUrl(), '/') . $this->getRepository()->getApiPath(); |
|
| 187 | + return rtrim($this->getUrl(), '/').$this->getRepository()->getApiPath(); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function userOptInPage(User $user) |
| 218 | 218 | { |
| 219 | - $localPageName = 'User:' . $user->getUsername() . '/EditCounterOptIn.js'; |
|
| 219 | + $localPageName = 'User:'.$user->getUsername().'/EditCounterOptIn.js'; |
|
| 220 | 220 | return $localPageName; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | // 4. Lastly, see if they've opted in globally on the default project or Meta. |
| 253 | - $globalPageName = $user->getUsername() . '/EditCounterGlobalOptIn.js'; |
|
| 253 | + $globalPageName = $user->getUsername().'/EditCounterGlobalOptIn.js'; |
|
| 254 | 254 | $globalProject = $this->getRepository()->getGlobalProject(); |
| 255 | 255 | if ($globalProject instanceof Project) { |
| 256 | 256 | $globalExists = $globalProject->getRepository() |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | */ |
| 270 | 270 | public function hasPageAssessments() |
| 271 | 271 | { |
| 272 | - return (bool) $this->getRepository()->getAssessmentsConfig($this->getDomain()); |
|
| 272 | + return (bool)$this->getRepository()->getAssessmentsConfig($this->getDomain()); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | $config = $this->getRepository()->getAssessmentsConfig($this->getDomain()); |
| 283 | 283 | |
| 284 | 284 | if (isset($config['class'][$class])) { |
| 285 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config['class'][$class]['badge']; |
|
| 285 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config['class'][$class]['badge']; |
|
| 286 | 286 | } elseif (isset($config['class']['Unknown'])) { |
| 287 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config['class']['Unknown']['badge']; |
|
| 287 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config['class']['Unknown']['badge']; |
|
| 288 | 288 | } else { |
| 289 | 289 | return ""; |
| 290 | 290 | } |
@@ -150,7 +150,7 @@ |
||
| 150 | 150 | // $tableExtension in order to generate the new table name |
| 151 | 151 | if ($this->isLabs() && $tableExtension !== null) { |
| 152 | 152 | $mapped = true; |
| 153 | - $tableName = $tableName . '_' . $tableExtension; |
|
| 153 | + $tableName = $tableName.'_'.$tableExtension; |
|
| 154 | 154 | } elseif ($this->container->hasParameter("app.table.$tableName")) { |
| 155 | 155 | // Use the table specified in the table mapping configuration, if present. |
| 156 | 156 | $mapped = true; |
@@ -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 | /** |
@@ -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'] |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | $dbName = $project->getDatabaseName(); |
| 145 | 145 | |
| 146 | - $cacheKey = 'editsummaryusage.' . $dbName . '.' |
|
| 147 | - . $user->getCacheKey() . '.' . $namespace; |
|
| 146 | + $cacheKey = 'editsummaryusage.'.$dbName.'.' |
|
| 147 | + . $user->getCacheKey().'.'.$namespace; |
|
| 148 | 148 | |
| 149 | 149 | $cache = $this->container->get('cache.app'); |
| 150 | 150 | if ($cache->hasItem($cacheKey)) { |
@@ -231,8 +231,7 @@ discard block |
||
| 231 | 231 | if ($row['rev_minor_edit'] == 0) { |
| 232 | 232 | if ($row['rev_comment'] !== '') { |
| 233 | 233 | isset($monthEditsummaryTotals[$monthkey]) ? |
| 234 | - $monthEditsummaryTotals[$monthkey]++ : |
|
| 235 | - $monthEditsummaryTotals[$monthkey] = 1; |
|
| 234 | + $monthEditsummaryTotals[$monthkey]++ : $monthEditsummaryTotals[$monthkey] = 1; |
|
| 236 | 235 | $totalSummariesMajor++; |
| 237 | 236 | } |
| 238 | 237 | |
@@ -249,8 +248,7 @@ discard block |
||
| 249 | 248 | // If there is a comment, count it |
| 250 | 249 | if ($row['rev_comment'] !== '') { |
| 251 | 250 | isset($monthEditsummaryTotals[$monthkey]) ? |
| 252 | - $monthEditsummaryTotals[$monthkey]++ : |
|
| 253 | - $monthEditsummaryTotals[$monthkey] = 1; |
|
| 251 | + $monthEditsummaryTotals[$monthkey]++ : $monthEditsummaryTotals[$monthkey] = 1; |
|
| 254 | 252 | $totalSummariesMinor++; |
| 255 | 253 | $totalEditsMinor++; |
| 256 | 254 | } else { |
@@ -11,9 +11,7 @@ |
||
| 11 | 11 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 12 | 12 | use Symfony\Component\HttpFoundation\Request; |
| 13 | 13 | use Symfony\Component\HttpFoundation\Response; |
| 14 | -use Psr\Cache\CacheItemPoolInterface; |
|
| 15 | 14 | use Xtools\Project; |
| 16 | -use Xtools\ProjectRepository; |
|
| 17 | 15 | use Xtools\User; |
| 18 | 16 | use DateTime; |
| 19 | 17 | use DateInterval; |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | * Display the Edit Summary results |
| 75 | 75 | * |
| 76 | 76 | * @param Request $request The HTTP request. |
| 77 | - * @param string $namespace Namespace ID or 'all' for all namespaces. |
|
| 77 | + * @param integer $namespace Namespace ID or 'all' for all namespaces. |
|
| 78 | 78 | * |
| 79 | 79 | * @Route("/editsummary/{project}/{username}/{namespace}", name="EditSummaryResult") |
| 80 | 80 | * |