@@ -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 | /** |
@@ -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 |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | $username = $request->query->get('username', $request->query->get('user')); |
| 48 | 48 | |
| 49 | 49 | if ($projectQuery != '' && $username != '') { |
| 50 | - return $this->redirectToRoute('AdminScoreResult', [ 'project' => $projectQuery, 'username' => $username ]); |
|
| 50 | + return $this->redirectToRoute('AdminScoreResult', ['project' => $projectQuery, 'username' => $username]); |
|
| 51 | 51 | } elseif ($projectQuery != '' && $project === null) { |
| 52 | - return $this->redirectToRoute('AdminScoreProject', [ 'project' => $projectQuery ]); |
|
| 52 | + return $this->redirectToRoute('AdminScoreProject', ['project' => $projectQuery]); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Set default project so we can populate the namespace selector. |
@@ -95,20 +95,20 @@ discard block |
||
| 95 | 95 | $archiveTable = $projectRepo->getTableName($dbName, 'archive'); |
| 96 | 96 | |
| 97 | 97 | // MULTIPLIERS (to review) |
| 98 | - $ACCT_AGE_MULT = 1.25; # 0 if = 365 jours |
|
| 99 | - $EDIT_COUNT_MULT = 1.25; # 0 if = 10 000 |
|
| 100 | - $USER_PAGE_MULT = 0.1; # 0 if = |
|
| 98 | + $ACCT_AGE_MULT = 1.25; # 0 if = 365 jours |
|
| 99 | + $EDIT_COUNT_MULT = 1.25; # 0 if = 10 000 |
|
| 100 | + $USER_PAGE_MULT = 0.1; # 0 if = |
|
| 101 | 101 | $PATROLS_MULT = 1; # 0 if = |
| 102 | - $BLOCKS_MULT = 1.4; # 0 if = 10 |
|
| 102 | + $BLOCKS_MULT = 1.4; # 0 if = 10 |
|
| 103 | 103 | $AFD_MULT = 1.15; |
| 104 | - $RECENT_ACTIVITY_MULT = 0.9; # 0 if = |
|
| 104 | + $RECENT_ACTIVITY_MULT = 0.9; # 0 if = |
|
| 105 | 105 | $AIV_MULT = 1.15; |
| 106 | - $EDIT_SUMMARIES_MULT = 0.8; # 0 if = |
|
| 107 | - $NAMESPACES_MULT = 1.0; # 0 if = |
|
| 106 | + $EDIT_SUMMARIES_MULT = 0.8; # 0 if = |
|
| 107 | + $NAMESPACES_MULT = 1.0; # 0 if = |
|
| 108 | 108 | $PAGES_CREATED_LIVE_MULT = 1.4; # 0 if = |
| 109 | 109 | $PAGES_CREATED_ARCHIVE_MULT = 1.4; # 0 if = |
| 110 | - $RPP_MULT = 1.15; # 0 if = |
|
| 111 | - $USERRIGHTS_MULT = 0.75; # 0 if = |
|
| 110 | + $RPP_MULT = 1.15; # 0 if = |
|
| 111 | + $USERRIGHTS_MULT = 0.75; # 0 if = |
|
| 112 | 112 | |
| 113 | 113 | // Grab the connection to the replica database (which is separate from the above) |
| 114 | 114 | $conn = $this->get('doctrine')->getManager("replicas")->getConnection(); |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | $now = new DateTime(); |
| 187 | 187 | $date = new DateTime($value); |
| 188 | 188 | $diff = $date->diff($now); |
| 189 | - $formula = 365*$diff->format("%y")+30*$diff->format("%m")+$diff->format("%d"); |
|
| 189 | + $formula = 365 * $diff->format("%y")+30 * $diff->format("%m")+$diff->format("%d"); |
|
| 190 | 190 | $value = $formula-365; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | if ($key == "id") { |
| 194 | 194 | $id = $value; |
| 195 | 195 | } else { |
| 196 | - $multiplierKey = strtoupper($row["source"] . "_MULT"); |
|
| 197 | - $multiplier = ( isset($$multiplierKey) ? $$multiplierKey : 1 ); |
|
| 196 | + $multiplierKey = strtoupper($row["source"]."_MULT"); |
|
| 197 | + $multiplier = (isset($$multiplierKey) ? $$multiplierKey : 1); |
|
| 198 | 198 | $score = max(min($value * $multiplier, 100), -100); |
| 199 | 199 | $master[$key]["mult"] = $multiplier; |
| 200 | 200 | $master[$key]["value"] = $value; |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | if ($id == 0) { |
| 207 | - $this->addFlash("notice", [ "no-result", $username ]); |
|
| 208 | - return $this->redirectToRoute("AdminScore", [ "project"=>$project ]); |
|
| 207 | + $this->addFlash("notice", ["no-result", $username]); |
|
| 208 | + return $this->redirectToRoute("AdminScore", ["project"=>$project]); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | return $this->render('adminscore/result.html.twig', [ |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function onKernelController(FilterControllerEvent $event) |
| 58 | 58 | { |
| 59 | - $this->rateLimit = (int) $this->container->getParameter('app.rate_limit_count'); |
|
| 60 | - $this->rateDuration = (int) $this->container->getParameter('app.rate_limit_time'); |
|
| 59 | + $this->rateLimit = (int)$this->container->getParameter('app.rate_limit_count'); |
|
| 60 | + $this->rateDuration = (int)$this->container->getParameter('app.rate_limit_time'); |
|
| 61 | 61 | |
| 62 | 62 | // Zero values indicate the rate limiting feature should be disabled. |
| 63 | 63 | if ($this->rateLimit === 0 || $this->rateDuration === 0) { |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $controller = $event->getController(); |
| 68 | - $loggedIn = (bool) $this->container->get('session')->get('logged_in_user'); |
|
| 68 | + $loggedIn = (bool)$this->container->get('session')->get('logged_in_user'); |
|
| 69 | 69 | |
| 70 | 70 | // No rate limits on index pages or if they are logged in. |
| 71 | 71 | if ($controller[1] === 'indexAction' || $loggedIn) { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $cacheItem = $cache->getItem($cacheKey); |
| 86 | 86 | |
| 87 | 87 | // If increment value already in cache, or start with 1. |
| 88 | - $count = $cacheItem->isHit() ? (int) $cacheItem->get() + 1 : 1; |
|
| 88 | + $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1; |
|
| 89 | 89 | |
| 90 | 90 | // Check if limit has been exceeded, and if so, throw an error. |
| 91 | 91 | if ($count > $this->rateLimit) { |
@@ -137,14 +137,14 @@ discard block |
||
| 137 | 137 | // Log the denied request |
| 138 | 138 | $logger = $this->container->get('monolog.logger.rate_limit'); |
| 139 | 139 | $logger->info( |
| 140 | - "<URI>: " . $request->getRequestUri() . |
|
| 141 | - ($logComment != '' ? "\t<Reason>: $logComment" : '') . |
|
| 142 | - "\t<User agent>: " . $request->headers->get('User-Agent') |
|
| 140 | + "<URI>: ".$request->getRequestUri(). |
|
| 141 | + ($logComment != '' ? "\t<Reason>: $logComment" : ''). |
|
| 142 | + "\t<User agent>: ".$request->headers->get('User-Agent') |
|
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | - throw new AccessDeniedHttpException("Possible spider crawl detected. " . |
|
| 146 | - 'If you are human, you are making too many requests during a short period of time. ' . |
|
| 147 | - "Please wait $this->rateDuration minutes before reloading this tool. You can then " . |
|
| 145 | + throw new AccessDeniedHttpException("Possible spider crawl detected. ". |
|
| 146 | + 'If you are human, you are making too many requests during a short period of time. '. |
|
| 147 | + "Please wait $this->rateDuration minutes before reloading this tool. You can then ". |
|
| 148 | 148 | 'login to prevent this from happening again.'); |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $neutral = $rfa->getSection("neutral"); |
| 171 | 171 | $dup = $rfa->getDuplicates(); |
| 172 | 172 | |
| 173 | - if ((sizeof($support) + sizeof($oppose) + sizeof($neutral)) == 0) { |
|
| 173 | + if ((sizeof($support)+sizeof($oppose)+sizeof($neutral)) == 0) { |
|
| 174 | 174 | $this->addFlash("notice", ["no-result", $pagename]); |
| 175 | 175 | return $this->redirectToRoute( |
| 176 | 176 | "rfxAnalysisProject", |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $end = $rfa->getEndDate(); |
| 184 | 184 | |
| 185 | 185 | $percent = (sizeof($support) / |
| 186 | - (sizeof($support) + sizeof($oppose) + sizeof($neutral))); |
|
| 186 | + (sizeof($support)+sizeof($oppose)+sizeof($neutral))); |
|
| 187 | 187 | |
| 188 | 188 | $percent = $percent * 100; |
| 189 | 189 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | public function groups($project, $username) |
| 61 | 61 | { |
| 62 | 62 | $this->setUp($project); |
| 63 | - $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
| 63 | + $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"]; |
|
| 64 | 64 | $query = new SimpleRequest('query', $params); |
| 65 | 65 | $result = []; |
| 66 | 66 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | public function globalGroups($project, $username) |
| 89 | 89 | { |
| 90 | 90 | $this->setUp($project); |
| 91 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
| 91 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
| 92 | 92 | $query = new SimpleRequest('query', $params); |
| 93 | 93 | $result = []; |
| 94 | 94 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $groups[] = "B"; |
| 139 | 139 | } |
| 140 | 140 | if (in_array("steward", $admin["groups"])) { |
| 141 | - $groups[] = "S" ; |
|
| 141 | + $groups[] = "S"; |
|
| 142 | 142 | } |
| 143 | 143 | if (in_array("checkuser", $admin["groups"])) { |
| 144 | 144 | $groups[] = "CU"; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | if (in_array("bot", $admin["groups"])) { |
| 150 | 150 | $groups[] = "Bot"; |
| 151 | 151 | } |
| 152 | - $result[ $admin["name"] ] = [ |
|
| 152 | + $result[$admin["name"]] = [ |
|
| 153 | 153 | "groups" => implode('/', $groups) |
| 154 | 154 | ]; |
| 155 | 155 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $normalized = []; |
| 183 | 183 | if (isset($result['query']['normalized'])) { |
| 184 | 184 | array_map( |
| 185 | - function ($e) use (&$normalized) { |
|
| 185 | + function($e) use (&$normalized) { |
|
| 186 | 186 | $normalized[$e['to']] = $e['from']; |
| 187 | 187 | }, |
| 188 | 188 | $result['query']['normalized'] |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
| 268 | 268 | $innerPromise = $this->api->getRequestAsync($query); |
| 269 | 269 | |
| 270 | - $innerPromise->then(function ($result) use (&$data) { |
|
| 270 | + $innerPromise->then(function($result) use (&$data) { |
|
| 271 | 271 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
| 272 | 272 | if (isset($result['error']) || !isset($result['query'])) { |
| 273 | 273 | return $data['promise']->resolve($data); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | |
| 366 | 366 | $titleText = join("|", $titles); |
| 367 | 367 | |
| 368 | - $params= [ |
|
| 368 | + $params = [ |
|
| 369 | 369 | "titles" => $titleText, |
| 370 | 370 | "prop" => "revisions", |
| 371 | 371 | "rvprop" =>"content" |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $final = []; // initialize the final array |
|
| 122 | + $final = []; // initialize the final array |
|
| 123 | 123 | $finalRaw = []; // Initialize the raw data array |
| 124 | 124 | |
| 125 | 125 | foreach ($this->data as $key => $value) { |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | $final = array_count_values($final); // find repetition and its count |
| 134 | 134 | |
| 135 | - $final = array_diff($final, [1]); // remove single occurrences |
|
| 135 | + $final = array_diff($final, [1]); // remove single occurrences |
|
| 136 | 136 | |
| 137 | 137 | $this->duplicates = array_keys($final); |
| 138 | 138 | } |