@@ -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"); |
|
@@ -164,7 +164,7 @@ |
||
| 164 | 164 | private function getRevCount() |
| 165 | 165 | { |
| 166 | 166 | $query = "SELECT COUNT(*) AS count FROM " . $this->revisionTable |
| 167 | - . " WHERE rev_page = '" . $this->pageInfo['id'] . "'"; |
|
| 167 | + . " WHERE rev_page = '" . $this->pageInfo['id'] . "'"; |
|
| 168 | 168 | $res = $this->conn->query($query)->fetchAll(); |
| 169 | 169 | return $res[0]['count']; |
| 170 | 170 | } |
@@ -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(); |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | $conn = $this->container->get('doctrine')->getManager('replicas')->getConnection(); |
| 400 | 400 | $res = $conn->query($query)->fetchAll(); |
| 401 | 401 | |
| 402 | - $terms = array_map(function ($entry) { |
|
| 402 | + $terms = array_map(function($entry) { |
|
| 403 | 403 | return $entry['term']; |
| 404 | 404 | }, $res); |
| 405 | 405 | |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | 'prio' => 2, |
| 411 | 411 | 'name' => 'Wikidata', |
| 412 | 412 | 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n |
| 413 | - 'explanation' => "See: <a target='_blank' " . |
|
| 413 | + 'explanation' => "See: <a target='_blank' ". |
|
| 414 | 414 | "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>", |
| 415 | 415 | ]; |
| 416 | 416 | } |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | 'prio' => 3, |
| 420 | 420 | 'name' => 'Wikidata', |
| 421 | 421 | 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n |
| 422 | - 'explanation' => "See: <a target='_blank' " . |
|
| 422 | + 'explanation' => "See: <a target='_blank' ". |
|
| 423 | 423 | "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>", |
| 424 | 424 | ]; |
| 425 | 425 | } |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | $query = "SELECT rev_id, rev_parent_id, rev_user_text, rev_user, rev_timestamp, |
| 437 | 437 | rev_minor_edit, rev_len, rev_comment |
| 438 | 438 | FROM $this->revisionTable |
| 439 | - WHERE rev_page = '" . $this->pageInfo['id'] . "' AND rev_timestamp > 1 |
|
| 439 | + WHERE rev_page = '".$this->pageInfo['id']."' AND rev_timestamp > 1 |
|
| 440 | 440 | ORDER BY rev_timestamp"; |
| 441 | 441 | |
| 442 | 442 | $res = $this->conn->query($query)->fetchAll(); |
@@ -456,14 +456,14 @@ discard block |
||
| 456 | 456 | return $rev['rev_len']; |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - $lastRev = $this->pageHistory[$revIndex - 1]; |
|
| 459 | + $lastRev = $this->pageHistory[$revIndex-1]; |
|
| 460 | 460 | |
| 461 | 461 | // TODO: Remove once T101631 is resolved |
| 462 | 462 | // Treat as zero change in size if rev_len of previous edit is missing |
| 463 | 463 | if ($lastRev['rev_len'] === null) { |
| 464 | 464 | return 0; |
| 465 | 465 | } else { |
| 466 | - return $rev['rev_len'] - $lastRev['rev_len']; |
|
| 466 | + return $rev['rev_len']-$lastRev['rev_len']; |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | |
@@ -484,12 +484,12 @@ discard block |
||
| 484 | 484 | // The month of the first edit. Used as a comparison when building the per-month data |
| 485 | 485 | $firstEditMonth = strtotime(date('Y-m-01, 00:00', strtotime($firstEdit['rev_timestamp']))); |
| 486 | 486 | |
| 487 | - $lastEdit = $this->pageHistory[ $revisionCount - 1 ]; |
|
| 488 | - $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[ $revisionCount - 2 ]; |
|
| 487 | + $lastEdit = $this->pageHistory[$revisionCount-1]; |
|
| 488 | + $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[$revisionCount-2]; |
|
| 489 | 489 | |
| 490 | 490 | // Now we can start our master array. This one will be HUGE! |
| 491 | 491 | $lastEditSize = ($revisionCount > 1) |
| 492 | - ? $lastEdit['rev_len'] - $secondLastEdit['rev_len'] |
|
| 492 | + ? $lastEdit['rev_len']-$secondLastEdit['rev_len'] |
|
| 493 | 493 | : $lastEdit['rev_len']; |
| 494 | 494 | $data = [ |
| 495 | 495 | 'general' => [ |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | // Increment year and month counts for all edits |
| 587 | 587 | $data['year_count'][$timestamp['year']]['all']++; |
| 588 | 588 | $data['year_count'][$timestamp['year']]['months'][$timestamp['month']]['all']++; |
| 589 | - $data['year_count'][$timestamp['year']]['size'] = (int) $rev['rev_len']; |
|
| 589 | + $data['year_count'][$timestamp['year']]['size'] = (int)$rev['rev_len']; |
|
| 590 | 590 | |
| 591 | 591 | $editsThisMonth = $data['year_count'][$timestamp['year']]['months'][$timestamp['month']]['all']; |
| 592 | 592 | if ($editsThisMonth > $data['max_edits_per_month']) { |
@@ -630,9 +630,9 @@ discard block |
||
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // determine if the next revision was a revert |
| 633 | - $nextRevision = isset($this->pageHistory[$i + 1]) ? $this->pageHistory[$i + 1] : null; |
|
| 633 | + $nextRevision = isset($this->pageHistory[$i+1]) ? $this->pageHistory[$i+1] : null; |
|
| 634 | 634 | $nextRevisionIsRevert = $nextRevision && |
| 635 | - $this->getDiffSize($i + 1) === -$diffSize && |
|
| 635 | + $this->getDiffSize($i+1) === -$diffSize && |
|
| 636 | 636 | $this->aeh->isRevert($nextRevision['rev_comment']); |
| 637 | 637 | |
| 638 | 638 | // don't count this edit as content removal if the next edit reverted it |
@@ -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 | } |
@@ -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; |
@@ -125,7 +125,7 @@ |
||
| 125 | 125 | /** @var LabsHelper $labsHelper */ |
| 126 | 126 | $labsHelper = $this->container->get('app.labs_helper'); |
| 127 | 127 | $sql = "SELECT rev_comment FROM ".$labsHelper->getTable('revision') |
| 128 | - ." WHERE rev_user=:userId ORDER BY rev_timestamp DESC LIMIT 1000"; |
|
| 128 | + ." WHERE rev_user=:userId ORDER BY rev_timestamp DESC LIMIT 1000"; |
|
| 129 | 129 | $resultQuery = $replicas->prepare($sql); |
| 130 | 130 | $resultQuery->bindParam("userId", $userId); |
| 131 | 131 | $resultQuery->execute(); |
@@ -176,7 +176,7 @@ |
||
| 176 | 176 | |
| 177 | 177 | // Iterate over query results, loading each user id into the array |
| 178 | 178 | while ($row = $res->fetch()) { |
| 179 | - $adminIdArr[] = $row["user_id"] ; |
|
| 179 | + $adminIdArr[] = $row["user_id"]; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // Set the query results to be useful in a sql statement. |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | $total = (int)$stmt->fetchColumn(); |
| 63 | 63 | $topEditCounts[$project['dbName']] = array_merge($project, ['total' => $total]); |
| 64 | 64 | } |
| 65 | - uasort($topEditCounts, function ($a, $b) { |
|
| 66 | - return $b['total'] - $a['total']; |
|
| 65 | + uasort($topEditCounts, function($a, $b) { |
|
| 66 | + return $b['total']-$a['total']; |
|
| 67 | 67 | }); |
| 68 | 68 | return array_slice($topEditCounts, 0, $numProjects); |
| 69 | 69 | } |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $revisionCounts = array_combine( |
| 136 | - array_map(function ($e) { |
|
| 136 | + array_map(function($e) { |
|
| 137 | 137 | return $e['source']; |
| 138 | 138 | }, $results), |
| 139 | - array_map(function ($e) { |
|
| 139 | + array_map(function($e) { |
|
| 140 | 140 | return $e['value']; |
| 141 | 141 | }, $results) |
| 142 | 142 | ); |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | // Count the number of days, accounting for when there's zero or one edit. |
| 145 | 145 | $revisionCounts['days'] = 0; |
| 146 | 146 | if (isset($revisionCounts['first']) && isset($revisionCounts['last'])) { |
| 147 | - $editingTimeInSeconds = ceil($revisionCounts['last'] - $revisionCounts['first']); |
|
| 148 | - $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds/(60*60*24) : 1; |
|
| 147 | + $editingTimeInSeconds = ceil($revisionCounts['last']-$revisionCounts['first']); |
|
| 148 | + $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds / (60 * 60 * 24) : 1; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Format the first and last dates. |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | : 0; |
| 158 | 158 | |
| 159 | 159 | // Sum deleted and live to make the total. |
| 160 | - $revisionCounts['total'] = $revisionCounts['deleted'] + $revisionCounts['live']; |
|
| 160 | + $revisionCounts['total'] = $revisionCounts['deleted']+$revisionCounts['live']; |
|
| 161 | 161 | |
| 162 | 162 | // Calculate the average number of live edits per day. |
| 163 | 163 | $revisionCounts['avg_per_day'] = round( |
@@ -196,16 +196,16 @@ discard block |
||
| 196 | 196 | $results = $resultQuery->fetchAll(); |
| 197 | 197 | |
| 198 | 198 | $pageCounts = array_combine( |
| 199 | - array_map(function ($e) { |
|
| 199 | + array_map(function($e) { |
|
| 200 | 200 | return $e['source']; |
| 201 | 201 | }, $results), |
| 202 | - array_map(function ($e) { |
|
| 202 | + array_map(function($e) { |
|
| 203 | 203 | return $e['value']; |
| 204 | 204 | }, $results) |
| 205 | 205 | ); |
| 206 | 206 | |
| 207 | 207 | // Total created. |
| 208 | - $pageCounts['created'] = $pageCounts['created-live'] + $pageCounts['created-deleted']; |
|
| 208 | + $pageCounts['created'] = $pageCounts['created-live']+$pageCounts['created-deleted']; |
|
| 209 | 209 | |
| 210 | 210 | // Calculate the average number of edits per page. |
| 211 | 211 | $pageCounts['edits_per_page'] = 0; |
@@ -232,17 +232,17 @@ discard block |
||
| 232 | 232 | $resultQuery->execute(); |
| 233 | 233 | $results = $resultQuery->fetchAll(); |
| 234 | 234 | $logCounts = array_combine( |
| 235 | - array_map(function ($e) { |
|
| 235 | + array_map(function($e) { |
|
| 236 | 236 | return $e['source']; |
| 237 | 237 | }, $results), |
| 238 | - array_map(function ($e) { |
|
| 238 | + array_map(function($e) { |
|
| 239 | 239 | return $e['value']; |
| 240 | 240 | }, $results) |
| 241 | 241 | ); |
| 242 | 242 | |
| 243 | 243 | // Make sure there is some value for each of the wanted counts. |
| 244 | 244 | $requiredCounts = [ |
| 245 | - 'thanks-thank', 'review-approve', 'patrol-patrol','block-block', 'block-unblock', |
|
| 245 | + 'thanks-thank', 'review-approve', 'patrol-patrol', 'block-block', 'block-unblock', |
|
| 246 | 246 | 'protect-protect', 'protect-unprotect', 'delete-delete', 'delete-revision', |
| 247 | 247 | 'delete-restore', 'import-import', 'upload-upload', 'upload-overwrite', |
| 248 | 248 | ]; |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // Merge approvals together. |
| 256 | - $logCounts['review-approve'] = $logCounts['review-approve'] + |
|
| 257 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
| 258 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
| 256 | + $logCounts['review-approve'] = $logCounts['review-approve']+ |
|
| 257 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
| 258 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
| 259 | 259 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
| 260 | 260 | |
| 261 | 261 | // Add Commons upload count, if applicable. |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | public function getNamespaceTotals($userId) |
| 281 | 281 | { |
| 282 | 282 | $sql = "SELECT page_namespace, count(rev_id) AS total |
| 283 | - FROM ".$this->labsHelper->getTable('revision') ." r |
|
| 283 | + FROM ".$this->labsHelper->getTable('revision')." r |
|
| 284 | 284 | JOIN ".$this->labsHelper->getTable('page')." p on r.rev_page = p.page_id |
| 285 | 285 | WHERE r.rev_user = :id GROUP BY page_namespace"; |
| 286 | 286 | $resultQuery = $this->replicas->prepare($sql); |
@@ -288,10 +288,10 @@ discard block |
||
| 288 | 288 | $resultQuery->execute(); |
| 289 | 289 | $results = $resultQuery->fetchAll(); |
| 290 | 290 | $namespaceTotals = array_combine( |
| 291 | - array_map(function ($e) { |
|
| 291 | + array_map(function($e) { |
|
| 292 | 292 | return $e['page_namespace']; |
| 293 | 293 | }, $results), |
| 294 | - array_map(function ($e) { |
|
| 294 | + array_map(function($e) { |
|
| 295 | 295 | return $e['total']; |
| 296 | 296 | }, $results) |
| 297 | 297 | ); |
@@ -316,8 +316,8 @@ discard block |
||
| 316 | 316 | $sql = |
| 317 | 317 | "SELECT rev_id, rev_comment, rev_timestamp, rev_minor_edit, rev_deleted, " |
| 318 | 318 | . " rev_len, rev_parent_id, page_title " |
| 319 | - . " FROM " . $this->labsHelper->getTable('revision', $project['dbName']) |
|
| 320 | - . " JOIN " . $this->labsHelper->getTable('page', $project['dbName']) |
|
| 319 | + . " FROM ".$this->labsHelper->getTable('revision', $project['dbName']) |
|
| 320 | + . " JOIN ".$this->labsHelper->getTable('page', $project['dbName']) |
|
| 321 | 321 | . " ON (rev_page = page_id)" |
| 322 | 322 | . " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" |
| 323 | 323 | . " ORDER BY rev_timestamp DESC" |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | continue; |
| 333 | 333 | } |
| 334 | 334 | $revsWithProject = array_map( |
| 335 | - function (&$item) use ($project) { |
|
| 335 | + function(&$item) use ($project) { |
|
| 336 | 336 | $item['project_name'] = $project['name']; |
| 337 | 337 | $item['project_url'] = $project['url']; |
| 338 | 338 | $item['project_db_name'] = $project['dbName']; |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | ); |
| 343 | 343 | $allRevisions = array_merge($allRevisions, $revsWithProject); |
| 344 | 344 | } |
| 345 | - usort($allRevisions, function ($a, $b) { |
|
| 346 | - return $b['rev_timestamp'] - $a['rev_timestamp']; |
|
| 345 | + usort($allRevisions, function($a, $b) { |
|
| 346 | + return $b['rev_timestamp']-$a['rev_timestamp']; |
|
| 347 | 347 | }); |
| 348 | 348 | return array_slice($allRevisions, 0, $contribCount); |
| 349 | 349 | } |
@@ -365,8 +365,8 @@ discard block |
||
| 365 | 365 | . " MONTH(rev_timestamp) AS `month`," |
| 366 | 366 | . " page_namespace," |
| 367 | 367 | . " COUNT(rev_id) AS `count` " |
| 368 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
| 369 | - . " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" |
|
| 368 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
| 369 | + . " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)" |
|
| 370 | 370 | . " WHERE rev_user_text = :username" |
| 371 | 371 | . " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " |
| 372 | 372 | . " ORDER BY rev_timestamp DESC"; |
@@ -422,10 +422,10 @@ discard block |
||
| 422 | 422 | . " SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`," |
| 423 | 423 | . " page_namespace," |
| 424 | 424 | . " COUNT(rev_id) AS `count` " |
| 425 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
| 426 | - . " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" . |
|
| 427 | - " WHERE rev_user_text = :username" . |
|
| 428 | - " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace " . |
|
| 425 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
| 426 | + . " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)". |
|
| 427 | + " WHERE rev_user_text = :username". |
|
| 428 | + " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace ". |
|
| 429 | 429 | " ORDER BY rev_timestamp DESC "; |
| 430 | 430 | $resultQuery = $this->replicas->prepare($sql); |
| 431 | 431 | $resultQuery->bindParam(":username", $username); |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | . " DAYOFWEEK(rev_timestamp) AS `y`, " |
| 467 | 467 | . " $xCalc AS `x`, " |
| 468 | 468 | . " COUNT(rev_id) AS `r` " |
| 469 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
| 469 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
| 470 | 470 | . " WHERE rev_user_text = :username" |
| 471 | 471 | . " GROUP BY DAYOFWEEK(rev_timestamp), $xCalc " |
| 472 | 472 | . " "; |