| @@ -380,7 +380,6 @@ | ||
| 380 | 380 | |
| 381 | 381 | /** | 
| 382 | 382 | * Get the size of the diff | 
| 383 | - * @param int $rev The index of the revision within $this->pageHistory | |
| 384 | 383 | * @return int Size of the diff | 
| 385 | 384 | */ | 
| 386 | 385 | private function getDiffSize($revIndex) | 
| @@ -55,9 +55,9 @@ discard block | ||
| 55 | 55 |          $article = $request->query->get('article'); | 
| 56 | 56 | |
| 57 | 57 |          if ($projectQuery != '' && $article != '') { | 
| 58 | -            return $this->redirectToRoute('ArticleInfoResult', [ 'project'=>$projectQuery, 'article' => $article ]); | |
| 58 | +            return $this->redirectToRoute('ArticleInfoResult', ['project'=>$projectQuery, 'article' => $article]); | |
| 59 | 59 |          } elseif ($article != '') { | 
| 60 | -            return $this->redirectToRoute('ArticleInfoProject', [ 'project'=>$projectQuery ]); | |
| 60 | +            return $this->redirectToRoute('ArticleInfoProject', ['project'=>$projectQuery]); | |
| 61 | 61 | } | 
| 62 | 62 | |
| 63 | 63 |          return $this->render('articleInfo/index.html.twig', [ | 
| @@ -102,7 +102,7 @@ discard block | ||
| 102 | 102 | 'url' => $basicInfo['fullurl'] | 
| 103 | 103 | ]; | 
| 104 | 104 | |
| 105 | - $this->pageInfo['watchers'] = ( isset($basicInfo['watchers']) ) ? $basicInfo['watchers'] : "< 30"; | |
| 105 | + $this->pageInfo['watchers'] = (isset($basicInfo['watchers'])) ? $basicInfo['watchers'] : "< 30"; | |
| 106 | 106 | |
| 107 | 107 | $pageProps = isset($basicInfo['pageprops']) ? $basicInfo['pageprops'] : []; | 
| 108 | 108 | |
| @@ -164,8 +164,8 @@ discard block | ||
| 164 | 164 | */ | 
| 165 | 165 | private function getRevCount() | 
| 166 | 166 |      { | 
| 167 | - $query = "SELECT COUNT(*) AS count FROM " . $this->revisionTable | |
| 168 | - . " WHERE rev_page = '" . $this->pageInfo['id'] . "'"; | |
| 167 | + $query = "SELECT COUNT(*) AS count FROM ".$this->revisionTable | |
| 168 | + . " WHERE rev_page = '".$this->pageInfo['id']."'"; | |
| 169 | 169 | $res = $this->conn->query($query)->fetchAll(); | 
| 170 | 170 | return $res[0]['count']; | 
| 171 | 171 | } | 
| @@ -197,7 +197,7 @@ discard block | ||
| 197 | 197 | FROM $this->revisionTable | 
| 198 | 198 | LEFT JOIN $userGroupsTable ON rev_user = ug_user | 
| 199 | 199 | LEFT JOIN $userFromerGroupsTable ON rev_user = ufg_user | 
| 200 | - WHERE rev_page = " . $this->pageInfo['id'] . " AND (ug_group = 'bot' OR ufg_group = 'bot') | |
| 200 | + WHERE rev_page = ".$this->pageInfo['id']." AND (ug_group = 'bot' OR ufg_group = 'bot') | |
| 201 | 201 | GROUP BY rev_user_text"; | 
| 202 | 202 | $res = $this->conn->query($query)->fetchAll(); | 
| 203 | 203 | |
| @@ -206,14 +206,14 @@ discard block | ||
| 206 | 206 | $sum = 0; | 
| 207 | 207 |          foreach ($res as $bot) { | 
| 208 | 208 | $bots[$bot['username']] = [ | 
| 209 | - 'count' => (int) $bot['count'], | |
| 209 | + 'count' => (int)$bot['count'], | |
| 210 | 210 | 'current' => $bot['current'] === 'bot' | 
| 211 | 211 | ]; | 
| 212 | 212 | $sum += $bot['count']; | 
| 213 | 213 | } | 
| 214 | 214 | |
| 215 | -        uasort($bots, function ($a, $b) { | |
| 216 | - return $b['count'] - $a['count']; | |
| 215 | +        uasort($bots, function($a, $b) { | |
| 216 | + return $b['count']-$a['count']; | |
| 217 | 217 | }); | 
| 218 | 218 | |
| 219 | 219 | $this->pageInfo['general']['bot_revision_count'] = $sum; | 
| @@ -249,10 +249,10 @@ discard block | ||
| 249 | 249 | |
| 250 | 250 |              if ($info['all'] > 1) { | 
| 251 | 251 | // Number of seconds between first and last edit | 
| 252 | - $secs = intval(strtotime($info['last']) - strtotime($info['first']) / $info['all']); | |
| 252 | + $secs = intval(strtotime($info['last'])-strtotime($info['first']) / $info['all']); | |
| 253 | 253 | |
| 254 | 254 | // Average time between edits (in days) | 
| 255 | - $this->pageInfo['editors'][$editor]['atbe'] = $secs / ( 60 * 60 * 24 ); | |
| 255 | + $this->pageInfo['editors'][$editor]['atbe'] = $secs / (60 * 60 * 24); | |
| 256 | 256 | } | 
| 257 | 257 | |
| 258 | 258 |              if (count($info['sizes'])) { | 
| @@ -298,7 +298,7 @@ discard block | ||
| 298 | 298 | |
| 299 | 299 | // Transform to associative array by 'type' | 
| 300 | 300 |          foreach ($res as $row) { | 
| 301 | - $data[$row['type'] . '_count'] = $row['value']; | |
| 301 | + $data[$row['type'].'_count'] = $row['value']; | |
| 302 | 302 | } | 
| 303 | 303 | |
| 304 | 304 | return $data; | 
| @@ -314,7 +314,7 @@ discard block | ||
| 314 | 314 |          $title = str_replace(' ', '_', $this->pageInfo['title']); | 
| 315 | 315 | $query = "SELECT log_action, log_type, log_timestamp AS timestamp | 
| 316 | 316 | FROM $loggingTable | 
| 317 | - WHERE log_namespace = '" . $this->pageInfo['namespace'] . "' | |
| 317 | + WHERE log_namespace = '".$this->pageInfo['namespace']."' | |
| 318 | 318 | AND log_title = '$title' AND log_timestamp > 1 | 
| 319 | 319 |                    AND log_type IN ('delete', 'move', 'protect', 'stable')"; | 
| 320 | 320 | $events = $this->conn->query($query)->fetchAll(); | 
| @@ -395,7 +395,7 @@ discard block | ||
| 395 | 395 |          $conn = $this->container->get('doctrine')->getManager('replicas')->getConnection(); | 
| 396 | 396 | $res = $conn->query($query)->fetchAll(); | 
| 397 | 397 | |
| 398 | -        $terms = array_map(function ($entry) { | |
| 398 | +        $terms = array_map(function($entry) { | |
| 399 | 399 | return $entry['term']; | 
| 400 | 400 | }, $res); | 
| 401 | 401 | |
| @@ -406,7 +406,7 @@ discard block | ||
| 406 | 406 | 'prio' => 2, | 
| 407 | 407 | 'name' => 'Wikidata', | 
| 408 | 408 | 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n | 
| 409 | - 'explanation' => "See: <a target='_blank' " . | |
| 409 | + 'explanation' => "See: <a target='_blank' ". | |
| 410 | 410 | "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>", | 
| 411 | 411 | ]; | 
| 412 | 412 | } | 
| @@ -415,7 +415,7 @@ discard block | ||
| 415 | 415 | 'prio' => 3, | 
| 416 | 416 | 'name' => 'Wikidata', | 
| 417 | 417 | 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n | 
| 418 | - 'explanation' => "See: <a target='_blank' " . | |
| 418 | + 'explanation' => "See: <a target='_blank' ". | |
| 419 | 419 | "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>", | 
| 420 | 420 | ]; | 
| 421 | 421 | } | 
| @@ -432,7 +432,7 @@ discard block | ||
| 432 | 432 | $query = "SELECT rev_id, rev_parent_id, rev_user_text, rev_user, rev_timestamp, | 
| 433 | 433 | rev_minor_edit, rev_len, rev_comment | 
| 434 | 434 | FROM $this->revisionTable | 
| 435 | - WHERE rev_page = '" . $this->pageInfo['id'] . "' AND rev_timestamp > 1 | |
| 435 | + WHERE rev_page = '".$this->pageInfo['id']."' AND rev_timestamp > 1 | |
| 436 | 436 | ORDER BY rev_timestamp"; | 
| 437 | 437 | |
| 438 | 438 | $res = $this->conn->query($query)->fetchAll(); | 
| @@ -452,9 +452,9 @@ discard block | ||
| 452 | 452 | return $rev['rev_len']; | 
| 453 | 453 | } | 
| 454 | 454 | |
| 455 | - $lastRev = $this->pageHistory[$revIndex - 1]; | |
| 455 | + $lastRev = $this->pageHistory[$revIndex-1]; | |
| 456 | 456 | |
| 457 | - return $rev['rev_len'] - $lastRev['rev_len']; | |
| 457 | + return $rev['rev_len']-$lastRev['rev_len']; | |
| 458 | 458 | } | 
| 459 | 459 | |
| 460 | 460 | /** | 
| @@ -474,12 +474,12 @@ discard block | ||
| 474 | 474 | // The month of the first edit. Used as a comparison when building the per-month data | 
| 475 | 475 |          $firstEditMonth = strtotime(date('Y-m-01, 00:00', strtotime($firstEdit['rev_timestamp']))); | 
| 476 | 476 | |
| 477 | - $lastEdit = $this->pageHistory[ $revisionCount - 1 ]; | |
| 478 | - $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[ $revisionCount - 2 ]; | |
| 477 | + $lastEdit = $this->pageHistory[$revisionCount-1]; | |
| 478 | + $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[$revisionCount-2]; | |
| 479 | 479 | |
| 480 | 480 | // Now we can start our master array. This one will be HUGE! | 
| 481 | 481 | $lastEditSize = ($revisionCount > 1) | 
| 482 | - ? $lastEdit['rev_len'] - $secondLastEdit['rev_len'] | |
| 482 | + ? $lastEdit['rev_len']-$secondLastEdit['rev_len'] | |
| 483 | 483 | : $lastEdit['rev_len']; | 
| 484 | 484 | $data = [ | 
| 485 | 485 | 'general' => [ | 
| @@ -576,7 +576,7 @@ discard block | ||
| 576 | 576 | // Increment year and month counts for all edits | 
| 577 | 577 | $data['year_count'][$timestamp['year']]['all']++; | 
| 578 | 578 | $data['year_count'][$timestamp['year']]['months'][$timestamp['month']]['all']++; | 
| 579 | - $data['year_count'][$timestamp['year']]['size'] = (int) $rev['rev_len']; | |
| 579 | + $data['year_count'][$timestamp['year']]['size'] = (int)$rev['rev_len']; | |
| 580 | 580 | |
| 581 | 581 | $editsThisMonth = $data['year_count'][$timestamp['year']]['months'][$timestamp['month']]['all']; | 
| 582 | 582 |              if ($editsThisMonth > $data['max_edits_per_month']) { | 
| @@ -620,9 +620,9 @@ discard block | ||
| 620 | 620 | } | 
| 621 | 621 | |
| 622 | 622 | // determine if the next revision was a revert | 
| 623 | - $nextRevision = isset($this->pageHistory[$i + 1]) ? $this->pageHistory[$i + 1] : null; | |
| 623 | + $nextRevision = isset($this->pageHistory[$i+1]) ? $this->pageHistory[$i+1] : null; | |
| 624 | 624 | $nextRevisionIsRevert = $nextRevision && | 
| 625 | - $this->getDiffSize($i + 1) === -$diffSize && | |
| 625 | + $this->getDiffSize($i+1) === -$diffSize && | |
| 626 | 626 | $this->aeh->isRevert($nextRevision['rev_comment']); | 
| 627 | 627 | |
| 628 | 628 | // don't count this edit as content removal if the next edit reverted it | 
| @@ -223,7 +223,7 @@ discard block | ||
| 223 | 223 | * Adds a mandatory requirement in form of a php.ini configuration. | 
| 224 | 224 | * | 
| 225 | 225 | * @param string $cfgName The configuration name used for ini_get() | 
| 226 | - * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, | |
| 226 | + * @param boolean|string $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, | |
| 227 | 227 | * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement | 
| 228 | 228 | * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. | 
| 229 | 229 | * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. | 
| @@ -241,7 +241,7 @@ discard block | ||
| 241 | 241 | * Adds an optional recommendation in form of a php.ini configuration. | 
| 242 | 242 | * | 
| 243 | 243 | * @param string $cfgName The configuration name used for ini_get() | 
| 244 | - * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, | |
| 244 | + * @param string|false $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, | |
| 245 | 245 | * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement | 
| 246 | 246 | * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. | 
| 247 | 247 | * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. | 
| @@ -49,11 +49,11 @@ discard block | ||
| 49 | 49 | */ | 
| 50 | 50 | public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false) | 
| 51 | 51 |      { | 
| 52 | - $this->fulfilled = (bool) $fulfilled; | |
| 53 | - $this->testMessage = (string) $testMessage; | |
| 54 | - $this->helpHtml = (string) $helpHtml; | |
| 55 | - $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText; | |
| 56 | - $this->optional = (bool) $optional; | |
| 52 | + $this->fulfilled = (bool)$fulfilled; | |
| 53 | + $this->testMessage = (string)$testMessage; | |
| 54 | + $this->helpHtml = (string)$helpHtml; | |
| 55 | + $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string)$helpText; | |
| 56 | + $this->optional = (bool)$optional; | |
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | 59 | /** | 
| @@ -544,7 +544,7 @@ discard block | ||
| 544 | 544 | ); | 
| 545 | 545 | } | 
| 546 | 546 | |
| 547 | -        $pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null; | |
| 547 | +        $pcreVersion = defined('PCRE_VERSION') ? (float)PCRE_VERSION : null; | |
| 548 | 548 | |
| 549 | 549 | $this->addRequirement( | 
| 550 | 550 | null !== $pcreVersion, | 
| @@ -783,7 +783,7 @@ discard block | ||
| 783 | 783 | $unit = ''; | 
| 784 | 784 |          if (!ctype_digit($size)) { | 
| 785 | 785 | $unit = strtolower(substr($size, -1, 1)); | 
| 786 | - $size = (int) substr($size, 0, -1); | |
| 786 | + $size = (int)substr($size, 0, -1); | |
| 787 | 787 | } | 
| 788 | 788 |          switch ($unit) { | 
| 789 | 789 | case 'g': | 
| @@ -793,7 +793,7 @@ discard block | ||
| 793 | 793 | case 'k': | 
| 794 | 794 | return $size * 1024; | 
| 795 | 795 | default: | 
| 796 | - return (int) $size; | |
| 796 | + return (int)$size; | |
| 797 | 797 | } | 
| 798 | 798 | } | 
| 799 | 799 | |
| @@ -815,7 +815,7 @@ discard block | ||
| 815 | 815 | continue; | 
| 816 | 816 | } | 
| 817 | 817 | |
| 818 | - return (int) $package['version'][1] > 2 ? self::REQUIRED_PHP_VERSION : self::LEGACY_REQUIRED_PHP_VERSION; | |
| 818 | + return (int)$package['version'][1] > 2 ? self::REQUIRED_PHP_VERSION : self::LEGACY_REQUIRED_PHP_VERSION; | |
| 819 | 819 | } | 
| 820 | 820 | |
| 821 | 821 | return false; | 
| @@ -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.'); | 
| @@ -15,11 +15,11 @@ | ||
| 15 | 15 | $data = json_decode($file, true); | 
| 16 | 16 | |
| 17 | 17 | // Output the contents to the piped file | 
| 18 | -print ( "parameters: | |
| 18 | +print ("parameters: | |
| 19 | 19 | automated_tools:\r\n" ); | 
| 20 | 20 |  foreach ($data as $row) { | 
| 21 | - print " - " . $row["name"] . ": '" . $row["regex"] . "'\r\n"; | |
| 21 | + print " - ".$row["name"].": '".$row["regex"]."'\r\n"; | |
| 22 | 22 | } | 
| 23 | -print ( " | |
| 23 | +print (" | |
| 24 | 24 | |
| 25 | - semi-automated edits source: $url" ); | |
| 25 | + semi-automated edits source: $url"); | |
| @@ -27,9 +27,9 @@ discard block | ||
| 27 | 27 |          $username = $request->query->get('user'); | 
| 28 | 28 | |
| 29 | 29 |          if ($projectQuery != "" && $username != "") { | 
| 30 | -            return $this->redirectToRoute("AdminScoreResult", [ 'project'=>$projectQuery, 'username' => $username ]); | |
| 30 | +            return $this->redirectToRoute("AdminScoreResult", ['project'=>$projectQuery, 'username' => $username]); | |
| 31 | 31 |          } elseif ($projectQuery != "") { | 
| 32 | -            return $this->redirectToRoute("AdminScoreProject", [ 'project'=>$projectQuery ]); | |
| 32 | +            return $this->redirectToRoute("AdminScoreProject", ['project'=>$projectQuery]); | |
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | 35 | // Otherwise fall through. | 
| @@ -67,20 +67,20 @@ discard block | ||
| 67 | 67 |          $archiveTable = $lh->getTable("archive", $dbName); | 
| 68 | 68 | |
| 69 | 69 | // MULTIPLIERS (to review) | 
| 70 | - $ACCT_AGE_MULT = 1.25; # 0 if = 365 jours | |
| 71 | - $EDIT_COUNT_MULT = 1.25; # 0 if = 10 000 | |
| 72 | - $USER_PAGE_MULT = 0.1; # 0 if = | |
| 70 | + $ACCT_AGE_MULT = 1.25; # 0 if = 365 jours | |
| 71 | + $EDIT_COUNT_MULT = 1.25; # 0 if = 10 000 | |
| 72 | + $USER_PAGE_MULT = 0.1; # 0 if = | |
| 73 | 73 | $PATROLS_MULT = 1; # 0 if = | 
| 74 | - $BLOCKS_MULT = 1.4; # 0 if = 10 | |
| 74 | + $BLOCKS_MULT = 1.4; # 0 if = 10 | |
| 75 | 75 | $AFD_MULT = 1.15; | 
| 76 | - $RECENT_ACTIVITY_MULT = 0.9; # 0 if = | |
| 76 | + $RECENT_ACTIVITY_MULT = 0.9; # 0 if = | |
| 77 | 77 | $AIV_MULT = 1.15; | 
| 78 | - $EDIT_SUMMARIES_MULT = 0.8; # 0 if = | |
| 79 | - $NAMESPACES_MULT = 1.0; # 0 if = | |
| 78 | + $EDIT_SUMMARIES_MULT = 0.8; # 0 if = | |
| 79 | + $NAMESPACES_MULT = 1.0; # 0 if = | |
| 80 | 80 | $PAGES_CREATED_LIVE_MULT = 1.4; # 0 if = | 
| 81 | 81 | $PAGES_CREATED_ARCHIVE_MULT = 1.4; # 0 if = | 
| 82 | - $RPP_MULT = 1.15; # 0 if = | |
| 83 | - $USERRIGHTS_MULT = 0.75; # 0 if = | |
| 82 | + $RPP_MULT = 1.15; # 0 if = | |
| 83 | + $USERRIGHTS_MULT = 0.75; # 0 if = | |
| 84 | 84 | |
| 85 | 85 | // Grab the connection to the replica database (which is separate from the above) | 
| 86 | 86 |          $conn = $this->get('doctrine')->getManager("replicas")->getConnection(); | 
| @@ -154,15 +154,15 @@ discard block | ||
| 154 | 154 | $now = new DateTime(); | 
| 155 | 155 | $date = new DateTime($value); | 
| 156 | 156 | $diff = $date->diff($now); | 
| 157 | -                $formula = 365*$diff->format("%y")+30*$diff->format("%m")+$diff->format("%d"); | |
| 157 | +                $formula = 365 * $diff->format("%y")+30 * $diff->format("%m")+$diff->format("%d"); | |
| 158 | 158 | $value = $formula-365; | 
| 159 | 159 | } | 
| 160 | 160 | |
| 161 | 161 |              if ($key == "id") { | 
| 162 | 162 | $id = $value; | 
| 163 | 163 |              } else { | 
| 164 | - $multiplierKey = strtoupper($row["source"] . "_MULT"); | |
| 165 | - $multiplier = ( isset($$multiplierKey) ? $$multiplierKey : 1 ); | |
| 164 | + $multiplierKey = strtoupper($row["source"]."_MULT"); | |
| 165 | + $multiplier = (isset($$multiplierKey) ? $$multiplierKey : 1); | |
| 166 | 166 | $score = max(min($value * $multiplier, 100), -100); | 
| 167 | 167 | $master[$key]["mult"] = $multiplier; | 
| 168 | 168 | $master[$key]["value"] = $value; | 
| @@ -172,8 +172,8 @@ discard block | ||
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | 174 |          if ($id == 0) { | 
| 175 | -            $this->addFlash("notice", [ "noresult", $username ]); | |
| 176 | -            return $this->redirectToRoute("AdminScore", [ "project"=>$project ]); | |
| 175 | +            $this->addFlash("notice", ["noresult", $username]); | |
| 176 | +            return $this->redirectToRoute("AdminScore", ["project"=>$project]); | |
| 177 | 177 | } | 
| 178 | 178 | |
| 179 | 179 | // replace this example code with whatever you need | 
| @@ -31,10 +31,10 @@ discard block | ||
| 31 | 31 |          $username = $request->query->get('user'); | 
| 32 | 32 | |
| 33 | 33 |          if ($projectQuery != "" && $username != "") { | 
| 34 | - $routeParams = [ 'project'=>$projectQuery, 'username' => $username ]; | |
| 34 | + $routeParams = ['project'=>$projectQuery, 'username' => $username]; | |
| 35 | 35 |              return $this->redirectToRoute("SimpleEditCounterResult", $routeParams); | 
| 36 | 36 |          } elseif ($projectQuery != "") { | 
| 37 | -            return $this->redirectToRoute("SimpleEditCounterProject", [ 'project'=>$projectQuery ]); | |
| 37 | +            return $this->redirectToRoute("SimpleEditCounterProject", ['project'=>$projectQuery]); | |
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | 40 | // Otherwise fall through. | 
| @@ -89,8 +89,8 @@ discard block | ||
| 89 | 89 | $resultQuery->execute(); | 
| 90 | 90 | |
| 91 | 91 |          if ($resultQuery->errorCode() > 0) { | 
| 92 | -            $this->addFlash("notice", [ "noresult", $username ]); | |
| 93 | -            return $this->redirectToRoute("SimpleEditCounterProject", [ "project"=>$project ]); | |
| 92 | +            $this->addFlash("notice", ["noresult", $username]); | |
| 93 | +            return $this->redirectToRoute("SimpleEditCounterProject", ["project"=>$project]); | |
| 94 | 94 | } | 
| 95 | 95 | |
| 96 | 96 | // Fetch the result data | 
| @@ -114,16 +114,16 @@ discard block | ||
| 114 | 114 | $rev = $row["value"]; | 
| 115 | 115 | } | 
| 116 | 116 |              if ($row["source"] == "groups") { | 
| 117 | - $groups .= $row["value"]. ", "; | |
| 117 | + $groups .= $row["value"].", "; | |
| 118 | 118 | } | 
| 119 | 119 | } | 
| 120 | 120 | |
| 121 | 121 | // Unknown user - If the user is created the $results variable will have 3 entries. | 
| 122 | 122 | // This is a workaround to detect non-existent IPs. | 
| 123 | 123 |          if (count($results) < 3 && $arch == 0 && $rev == 0) { | 
| 124 | -            $this->addFlash('notice', [ "noresult", $username ]); | |
| 124 | +            $this->addFlash('notice', ["noresult", $username]); | |
| 125 | 125 | |
| 126 | -            return $this->redirectToRoute("SimpleEditCounterProject", [ "project"=>$project ]); | |
| 126 | +            return $this->redirectToRoute("SimpleEditCounterProject", ["project"=>$project]); | |
| 127 | 127 | } | 
| 128 | 128 | |
| 129 | 129 | // Remove the last comma and space | 
| @@ -152,7 +152,7 @@ discard block | ||
| 152 | 152 | 'project_url' => $url, | 
| 153 | 153 | 'id' => $id, | 
| 154 | 154 | 'arch' => $arch, | 
| 155 | - 'rev' => $rev + $arch, | |
| 155 | + 'rev' => $rev+$arch, | |
| 156 | 156 | 'live' => $rev, | 
| 157 | 157 | 'groups' => $groups, | 
| 158 | 158 | 'globalGroups' => $globalGroups, | 
| @@ -12,8 +12,8 @@ discard block | ||
| 12 | 12 |          $title = str_replace(' ', '_', $title); | 
| 13 | 13 | $client = new GuzzleHttp\Client(); | 
| 14 | 14 | |
| 15 | - $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/' . | |
| 16 | - "$project/all-access/user/" . rawurlencode($title) . '/daily/' . $start . '/' . $end; | |
| 15 | + $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/'. | |
| 16 | + "$project/all-access/user/".rawurlencode($title).'/daily/'.$start.'/'.$end; | |
| 17 | 17 | |
| 18 | 18 |          $res = $client->request('GET', $url); | 
| 19 | 19 | return json_decode($res->getBody()->getContents()); | 
| @@ -32,7 +32,7 @@ discard block | ||
| 32 | 32 | $data = $this->getLastDays($project, $title, $days); | 
| 33 | 33 | |
| 34 | 34 | // FIXME: needs to handle gotchas | 
| 35 | -        return array_sum(array_map(function ($item) { | |
| 35 | +        return array_sum(array_map(function($item) { | |
| 36 | 36 | return $item->views; | 
| 37 | 37 | }, $data->items)); | 
| 38 | 38 | } | 
| @@ -45,7 +45,7 @@ | ||
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | 47 | // Find the path, and complain if English doesn't exist. | 
| 48 | -        $path = $this->container->getParameter("kernel.root_dir") . '/../i18n'; | |
| 48 | +        $path = $this->container->getParameter("kernel.root_dir").'/../i18n'; | |
| 49 | 49 |          if (!file_exists("$path/en.json")) { | 
| 50 | 50 |              throw new Exception("Language directory doesn't exist: $path"); | 
| 51 | 51 | } | 
| @@ -146,7 +146,7 @@ | ||
| 146 | 146 | |
| 147 | 147 | /** | 
| 148 | 148 | * | 
| 149 | - * @param $username | |
| 149 | + * @param string $username | |
| 150 | 150 | * @return integer | 
| 151 | 151 | */ | 
| 152 | 152 | public function getPageCounts($username, $totalRevisions) | 
| @@ -36,7 +36,7 @@ discard block | ||
| 36 | 36 | */ | 
| 37 | 37 | public function getUserId($usernameOrIp) | 
| 38 | 38 |      { | 
| 39 | - $cacheKey = 'userid.' . $usernameOrIp; | |
| 39 | + $cacheKey = 'userid.'.$usernameOrIp; | |
| 40 | 40 |          if ($this->cacheHas($cacheKey)) { | 
| 41 | 41 | return $cacheKey; | 
| 42 | 42 | } | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | /** @var ApiHelper */ | 
| 64 | 64 |          $api = $this->container->get('app.api_helper'); | 
| 65 | 65 |          foreach ($this->labsHelper->allProjects() as $project) { | 
| 66 | - $cacheKey = 'topprojects.' . $project['dbName'] . '.' . $username; | |
| 66 | + $cacheKey = 'topprojects.'.$project['dbName'].'.'.$username; | |
| 67 | 67 |              if ($this->cacheHas($cacheKey)) { | 
| 68 | 68 | $total = $this->cacheGet($cacheKey); | 
| 69 | 69 |              } else { | 
| @@ -83,8 +83,8 @@ discard block | ||
| 83 | 83 | } | 
| 84 | 84 | $topEditCounts[$project['dbName']] = array_merge($project, ['total' => $total]); | 
| 85 | 85 | } | 
| 86 | -        uasort($topEditCounts, function ($a, $b) { | |
| 87 | - return $b['total'] - $a['total']; | |
| 86 | +        uasort($topEditCounts, function($a, $b) { | |
| 87 | + return $b['total']-$a['total']; | |
| 88 | 88 | }); | 
| 89 | 89 | return array_slice($topEditCounts, 0, $numProjects); | 
| 90 | 90 | } | 
| @@ -154,10 +154,10 @@ discard block | ||
| 154 | 154 | } | 
| 155 | 155 | |
| 156 | 156 | $revisionCounts = array_combine( | 
| 157 | -            array_map(function ($e) { | |
| 157 | +            array_map(function($e) { | |
| 158 | 158 | return $e['source']; | 
| 159 | 159 | }, $results), | 
| 160 | -            array_map(function ($e) { | |
| 160 | +            array_map(function($e) { | |
| 161 | 161 | return $e['value']; | 
| 162 | 162 | }, $results) | 
| 163 | 163 | ); | 
| @@ -165,8 +165,8 @@ discard block | ||
| 165 | 165 | // Count the number of days, accounting for when there's zero or one edit. | 
| 166 | 166 | $revisionCounts['days'] = 0; | 
| 167 | 167 |          if (isset($revisionCounts['first']) && isset($revisionCounts['last'])) { | 
| 168 | - $editingTimeInSeconds = ceil($revisionCounts['last'] - $revisionCounts['first']); | |
| 169 | - $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds/(60*60*24) : 1; | |
| 168 | + $editingTimeInSeconds = ceil($revisionCounts['last']-$revisionCounts['first']); | |
| 169 | + $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds / (60 * 60 * 24) : 1; | |
| 170 | 170 | } | 
| 171 | 171 | |
| 172 | 172 | // Format the first and last dates. | 
| @@ -178,7 +178,7 @@ discard block | ||
| 178 | 178 | : 0; | 
| 179 | 179 | |
| 180 | 180 | // Sum deleted and live to make the total. | 
| 181 | - $revisionCounts['total'] = $revisionCounts['deleted'] + $revisionCounts['live']; | |
| 181 | + $revisionCounts['total'] = $revisionCounts['deleted']+$revisionCounts['live']; | |
| 182 | 182 | |
| 183 | 183 | // Calculate the average number of live edits per day. | 
| 184 | 184 | $revisionCounts['avg_per_day'] = round( | 
| @@ -222,16 +222,16 @@ discard block | ||
| 222 | 222 | $results = $resultQuery->fetchAll(); | 
| 223 | 223 | |
| 224 | 224 | $pageCounts = array_combine( | 
| 225 | -            array_map(function ($e) { | |
| 225 | +            array_map(function($e) { | |
| 226 | 226 | return $e['source']; | 
| 227 | 227 | }, $results), | 
| 228 | -            array_map(function ($e) { | |
| 228 | +            array_map(function($e) { | |
| 229 | 229 | return $e['value']; | 
| 230 | 230 | }, $results) | 
| 231 | 231 | ); | 
| 232 | 232 | |
| 233 | 233 | // Total created. | 
| 234 | - $pageCounts['created'] = $pageCounts['created-live'] + $pageCounts['created-deleted']; | |
| 234 | + $pageCounts['created'] = $pageCounts['created-live']+$pageCounts['created-deleted']; | |
| 235 | 235 | |
| 236 | 236 | // Calculate the average number of edits per page. | 
| 237 | 237 | $pageCounts['edits_per_page'] = 0; | 
| @@ -260,17 +260,17 @@ discard block | ||
| 260 | 260 | $resultQuery->execute(); | 
| 261 | 261 | $results = $resultQuery->fetchAll(); | 
| 262 | 262 | $logCounts = array_combine( | 
| 263 | -            array_map(function ($e) { | |
| 263 | +            array_map(function($e) { | |
| 264 | 264 | return $e['source']; | 
| 265 | 265 | }, $results), | 
| 266 | -            array_map(function ($e) { | |
| 266 | +            array_map(function($e) { | |
| 267 | 267 | return $e['value']; | 
| 268 | 268 | }, $results) | 
| 269 | 269 | ); | 
| 270 | 270 | |
| 271 | 271 | // Make sure there is some value for each of the wanted counts. | 
| 272 | 272 | $requiredCounts = [ | 
| 273 | - 'thanks-thank', 'review-approve', 'patrol-patrol','block-block', 'block-unblock', | |
| 273 | + 'thanks-thank', 'review-approve', 'patrol-patrol', 'block-block', 'block-unblock', | |
| 274 | 274 | 'protect-protect', 'protect-unprotect', 'delete-delete', 'delete-revision', | 
| 275 | 275 | 'delete-restore', 'import-import', 'upload-upload', 'upload-overwrite', | 
| 276 | 276 | ]; | 
| @@ -281,9 +281,9 @@ discard block | ||
| 281 | 281 | } | 
| 282 | 282 | |
| 283 | 283 | // Merge approvals together. | 
| 284 | - $logCounts['review-approve'] = $logCounts['review-approve'] + | |
| 285 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + | |
| 286 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + | |
| 284 | + $logCounts['review-approve'] = $logCounts['review-approve']+ | |
| 285 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ | |
| 286 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ | |
| 287 | 287 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); | 
| 288 | 288 | |
| 289 | 289 | // Add Commons upload count, if applicable. | 
| @@ -309,7 +309,7 @@ discard block | ||
| 309 | 309 |      { | 
| 310 | 310 | $userId = $this->getUserId($username); | 
| 311 | 311 | $sql = "SELECT page_namespace, count(rev_id) AS total | 
| 312 | -            FROM ".$this->labsHelper->getTable('revision') ." r | |
| 312 | +            FROM ".$this->labsHelper->getTable('revision')." r | |
| 313 | 313 |                  JOIN ".$this->labsHelper->getTable('page')." p on r.rev_page = p.page_id | 
| 314 | 314 | WHERE r.rev_user = :id GROUP BY page_namespace"; | 
| 315 | 315 | $resultQuery = $this->replicas->prepare($sql); | 
| @@ -317,10 +317,10 @@ discard block | ||
| 317 | 317 | $resultQuery->execute(); | 
| 318 | 318 | $results = $resultQuery->fetchAll(); | 
| 319 | 319 | $namespaceTotals = array_combine( | 
| 320 | -            array_map(function ($e) { | |
| 320 | +            array_map(function($e) { | |
| 321 | 321 | return $e['page_namespace']; | 
| 322 | 322 | }, $results), | 
| 323 | -            array_map(function ($e) { | |
| 323 | +            array_map(function($e) { | |
| 324 | 324 | return $e['total']; | 
| 325 | 325 | }, $results) | 
| 326 | 326 | ); | 
| @@ -346,8 +346,8 @@ discard block | ||
| 346 | 346 | "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, " | 
| 347 | 347 | . " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, " | 
| 348 | 348 | . " page_title, page_namespace " | 
| 349 | -                    . " FROM " . $this->labsHelper->getTable('revision', $project['dbName']) | |
| 350 | -                    . "    JOIN " . $this->labsHelper->getTable('page', $project['dbName']) | |
| 349 | +                    . " FROM ".$this->labsHelper->getTable('revision', $project['dbName']) | |
| 350 | +                    . "    JOIN ".$this->labsHelper->getTable('page', $project['dbName']) | |
| 351 | 351 | . " ON (rev_page = page_id)" | 
| 352 | 352 | . " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" | 
| 353 | 353 | . " ORDER BY rev_timestamp DESC" | 
| @@ -362,7 +362,7 @@ discard block | ||
| 362 | 362 | continue; | 
| 363 | 363 | } | 
| 364 | 364 | $revsWithProject = array_map( | 
| 365 | -                function (&$item) use ($project) { | |
| 365 | +                function(&$item) use ($project) { | |
| 366 | 366 | $item['project_name'] = $project['name']; | 
| 367 | 367 | $item['project_url'] = $project['url']; | 
| 368 | 368 | $item['project_db_name'] = $project['dbName']; | 
| @@ -373,8 +373,8 @@ discard block | ||
| 373 | 373 | ); | 
| 374 | 374 | $allRevisions = array_merge($allRevisions, $revsWithProject); | 
| 375 | 375 | } | 
| 376 | -        usort($allRevisions, function ($a, $b) { | |
| 377 | - return $b['rev_timestamp'] - $a['rev_timestamp']; | |
| 376 | +        usort($allRevisions, function($a, $b) { | |
| 377 | + return $b['rev_timestamp']-$a['rev_timestamp']; | |
| 378 | 378 | }); | 
| 379 | 379 | return array_slice($allRevisions, 0, $contribCount); | 
| 380 | 380 | } | 
| @@ -396,8 +396,8 @@ discard block | ||
| 396 | 396 | . " MONTH(rev_timestamp) AS `month`," | 
| 397 | 397 | . " page_namespace," | 
| 398 | 398 | . " COUNT(rev_id) AS `count` " | 
| 399 | -            . " FROM " . $this->labsHelper->getTable('revision') | |
| 400 | -            . "    JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" | |
| 399 | +            . " FROM ".$this->labsHelper->getTable('revision') | |
| 400 | +            . "    JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)" | |
| 401 | 401 | . " WHERE rev_user_text = :username" | 
| 402 | 402 | . " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " | 
| 403 | 403 | . " ORDER BY rev_timestamp DESC"; | 
| @@ -453,10 +453,10 @@ discard block | ||
| 453 | 453 | . " SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`," | 
| 454 | 454 | . " page_namespace," | 
| 455 | 455 | . " COUNT(rev_id) AS `count` " | 
| 456 | -            . " FROM " . $this->labsHelper->getTable('revision') | |
| 457 | -            . "    JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" . | |
| 458 | - " WHERE rev_user_text = :username" . | |
| 459 | - " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace " . | |
| 456 | +            . " FROM ".$this->labsHelper->getTable('revision') | |
| 457 | +            . "    JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)". | |
| 458 | + " WHERE rev_user_text = :username". | |
| 459 | + " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace ". | |
| 460 | 460 | " ORDER BY rev_timestamp DESC "; | 
| 461 | 461 | $resultQuery = $this->replicas->prepare($sql); | 
| 462 | 462 |          $resultQuery->bindParam(":username", $username); | 
| @@ -497,7 +497,7 @@ discard block | ||
| 497 | 497 | . " DAYOFWEEK(rev_timestamp) AS `y`, " | 
| 498 | 498 | . " $xCalc AS `x`, " | 
| 499 | 499 | . " COUNT(rev_id) AS `r` " | 
| 500 | -            . " FROM " . $this->labsHelper->getTable('revision') | |
| 500 | +            . " FROM ".$this->labsHelper->getTable('revision') | |
| 501 | 501 | . " WHERE rev_user_text = :username" | 
| 502 | 502 | . " GROUP BY DAYOFWEEK(rev_timestamp), $xCalc " | 
| 503 | 503 | . " "; |