@@ -179,7 +179,7 @@ |
||
| 179 | 179 | $this->recordApiUsage('project/adminstats'); |
| 180 | 180 | |
| 181 | 181 | // Maximum 30 days. |
| 182 | - $days = min((int) $days, 30); |
|
| 182 | + $days = min((int)$days, 30); |
|
| 183 | 183 | $start = date('Y-m-d', strtotime("-$days days")); |
| 184 | 184 | $end = date('Y-m-d'); |
| 185 | 185 | |
@@ -161,7 +161,7 @@ |
||
| 161 | 161 | */ |
| 162 | 162 | public function getTotalEditCount() |
| 163 | 163 | { |
| 164 | - return $this->data['deletedEditCount'] + $this->data['liveEditCount']; |
|
| 164 | + return $this->data['deletedEditCount']+$this->data['liveEditCount']; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $timeline = []; |
| 96 | 96 | $startObj = new DateTime($start); |
| 97 | 97 | $endObj = new DateTime($end); |
| 98 | - $numDays = (int) $endObj->diff($startObj)->format("%a"); |
|
| 98 | + $numDays = (int)$endObj->diff($startObj)->format("%a"); |
|
| 99 | 99 | $grandSum = 0; |
| 100 | 100 | |
| 101 | 101 | // Generate array of date labels |
@@ -105,17 +105,17 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | foreach ($data as $entry) { |
| 107 | 107 | if (!isset($totals[$entry['tool']])) { |
| 108 | - $totals[$entry['tool']] = (int) $entry['count']; |
|
| 108 | + $totals[$entry['tool']] = (int)$entry['count']; |
|
| 109 | 109 | |
| 110 | 110 | // Create arrays for each tool, filled with zeros for each date in the timeline |
| 111 | 111 | $timeline[$entry['tool']] = array_fill(0, $numDays, 0); |
| 112 | 112 | } else { |
| 113 | - $totals[$entry['tool']] += (int) $entry['count']; |
|
| 113 | + $totals[$entry['tool']] += (int)$entry['count']; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $date = new DateTime($entry['date']); |
| 117 | - $dateIndex = (int) $date->diff($startObj)->format("%a"); |
|
| 118 | - $timeline[$entry['tool']][$dateIndex] = (int) $entry['count']; |
|
| 117 | + $dateIndex = (int)$date->diff($startObj)->format("%a"); |
|
| 118 | + $timeline[$entry['tool']][$dateIndex] = (int)$entry['count']; |
|
| 119 | 119 | |
| 120 | 120 | $grandSum += $entry['count']; |
| 121 | 121 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $timeline = []; |
| 153 | 153 | $startObj = new DateTime($start); |
| 154 | 154 | $endObj = new DateTime($end); |
| 155 | - $numDays = (int) $endObj->diff($startObj)->format("%a"); |
|
| 155 | + $numDays = (int)$endObj->diff($startObj)->format("%a"); |
|
| 156 | 156 | $grandSum = 0; |
| 157 | 157 | |
| 158 | 158 | // Generate array of date labels |
@@ -162,17 +162,17 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | foreach ($data as $entry) { |
| 164 | 164 | if (!isset($totals[$entry['endpoint']])) { |
| 165 | - $totals[$entry['endpoint']] = (int) $entry['count']; |
|
| 165 | + $totals[$entry['endpoint']] = (int)$entry['count']; |
|
| 166 | 166 | |
| 167 | 167 | // Create arrays for each endpoint, filled with zeros for each date in the timeline |
| 168 | 168 | $timeline[$entry['endpoint']] = array_fill(0, $numDays, 0); |
| 169 | 169 | } else { |
| 170 | - $totals[$entry['endpoint']] += (int) $entry['count']; |
|
| 170 | + $totals[$entry['endpoint']] += (int)$entry['count']; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | $date = new DateTime($entry['date']); |
| 174 | - $dateIndex = (int) $date->diff($startObj)->format("%a"); |
|
| 175 | - $timeline[$entry['endpoint']][$dateIndex] = (int) $entry['count']; |
|
| 174 | + $dateIndex = (int)$date->diff($startObj)->format("%a"); |
|
| 175 | + $timeline[$entry['endpoint']][$dateIndex] = (int)$entry['count']; |
|
| 176 | 176 | |
| 177 | 177 | $grandSum += $entry['count']; |
| 178 | 178 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | $conn = $this->container->get('doctrine')->getManager('default')->getConnection(); |
| 222 | - $date = date('Y-m-d'); |
|
| 222 | + $date = date('Y-m-d'); |
|
| 223 | 223 | |
| 224 | 224 | // Increment count in timeline |
| 225 | 225 | $existsSql = "SELECT 1 FROM usage_timeline |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $info = $this->getPageInfo(); |
| 93 | 93 | $title = isset($info['title']) ? $info['title'] : $this->unnormalizedPageName; |
| 94 | 94 | $nsName = $this->getNamespaceName(); |
| 95 | - return str_replace($nsName . ':', '', $title); |
|
| 95 | + return str_replace($nsName.':', '', $title); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | { |
| 231 | 231 | // If a user is given, we will not cache the result via instance variable. |
| 232 | 232 | if ($user !== null) { |
| 233 | - return (int) $this->getRepository()->getNumRevisions($this, $user, $start, $end); |
|
| 233 | + return (int)$this->getRepository()->getNumRevisions($this, $user, $start, $end); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // Return cached value, if present. |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $this->numRevisions = count($this->revisions); |
| 244 | 244 | } else { |
| 245 | 245 | // Otherwise do a COUNT in the event fetching all revisions is not desired. |
| 246 | - $this->numRevisions = (int) $this->getRepository()->getNumRevisions($this, null, $start, $end); |
|
| 246 | + $this->numRevisions = (int)$this->getRepository()->getNumRevisions($this, null, $start, $end); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | return $this->numRevisions; |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | { |
| 276 | 276 | $content = $this->getRepository()->getPagesWikitext( |
| 277 | 277 | $this->getProject(), |
| 278 | - [ $this->getTitle() ] |
|
| 278 | + [$this->getTitle()] |
|
| 279 | 279 | ); |
| 280 | 280 | |
| 281 | 281 | return isset($content[$this->getTitle()]) |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | |
| 441 | 441 | $wikidataInfo = $this->getRepository()->getWikidataInfo($this); |
| 442 | 442 | |
| 443 | - $terms = array_map(function ($entry) { |
|
| 443 | + $terms = array_map(function($entry) { |
|
| 444 | 444 | return $entry['term']; |
| 445 | 445 | }, $wikidataInfo); |
| 446 | 446 | |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | 'prio' => 2, |
| 452 | 452 | 'name' => 'Wikidata', |
| 453 | 453 | 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n |
| 454 | - 'explanation' => "See: <a target='_blank' " . |
|
| 454 | + 'explanation' => "See: <a target='_blank' ". |
|
| 455 | 455 | "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>", |
| 456 | 456 | ]; |
| 457 | 457 | } |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | 'prio' => 3, |
| 462 | 462 | 'name' => 'Wikidata', |
| 463 | 463 | 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n |
| 464 | - 'explanation' => "See: <a target='_blank' " . |
|
| 464 | + 'explanation' => "See: <a target='_blank' ". |
|
| 465 | 465 | "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>", |
| 466 | 466 | ]; |
| 467 | 467 | } |
@@ -540,8 +540,8 @@ discard block |
||
| 540 | 540 | return 0; |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - return array_sum(array_map(function ($item) { |
|
| 544 | - return (int) $item['views']; |
|
| 543 | + return array_sum(array_map(function($item) { |
|
| 544 | + return (int)$item['views']; |
|
| 545 | 545 | }, $pageviews['items'])); |
| 546 | 546 | } |
| 547 | 547 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | public function getMaxRevisions() |
| 253 | 253 | { |
| 254 | 254 | if (!isset($this->maxRevisions)) { |
| 255 | - $this->maxRevisions = (int) $this->container->getParameter('app.max_page_revisions'); |
|
| 255 | + $this->maxRevisions = (int)$this->container->getParameter('app.max_page_revisions'); |
|
| 256 | 256 | } |
| 257 | 257 | return $this->maxRevisions; |
| 258 | 258 | } |
@@ -941,7 +941,7 @@ discard block |
||
| 941 | 941 | $this->yearMonthCounts[$editYear]['all']++; |
| 942 | 942 | $this->yearMonthCounts[$editYear]['months'][$editMonth]['all']++; |
| 943 | 943 | // This will ultimately be the size of the page by the end of the year |
| 944 | - $this->yearMonthCounts[$editYear]['size'] = (int) $edit->getLength(); |
|
| 944 | + $this->yearMonthCounts[$editYear]['size'] = (int)$edit->getLength(); |
|
| 945 | 945 | |
| 946 | 946 | // Keep track of which month had the most edits |
| 947 | 947 | $editsThisMonth = $this->yearMonthCounts[$editYear]['months'][$editMonth]['all']; |
@@ -960,7 +960,7 @@ discard block |
||
| 960 | 960 | $editYear = $edit->getYear(); |
| 961 | 961 | |
| 962 | 962 | // Beginning of the month at 00:00:00. |
| 963 | - $firstEditTime = mktime(0, 0, 0, (int) $this->firstEdit->getMonth(), 1, $this->firstEdit->getYear()); |
|
| 963 | + $firstEditTime = mktime(0, 0, 0, (int)$this->firstEdit->getMonth(), 1, $this->firstEdit->getYear()); |
|
| 964 | 964 | |
| 965 | 965 | $this->yearMonthCounts[$editYear] = [ |
| 966 | 966 | 'all' => 0, |
@@ -1095,14 +1095,14 @@ discard block |
||
| 1095 | 1095 | $botData = $this->getRepository()->getBotData($this->page, $this->startDate, $this->endDate); |
| 1096 | 1096 | while ($bot = $botData->fetch()) { |
| 1097 | 1097 | $bots[$bot['username']] = [ |
| 1098 | - 'count' => (int) $bot['count'], |
|
| 1098 | + 'count' => (int)$bot['count'], |
|
| 1099 | 1099 | 'current' => $bot['current'] === 'bot', |
| 1100 | 1100 | ]; |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | // Sort by edit count. |
| 1104 | - uasort($bots, function ($a, $b) { |
|
| 1105 | - return $b['count'] - $a['count']; |
|
| 1104 | + uasort($bots, function($a, $b) { |
|
| 1105 | + return $b['count']-$a['count']; |
|
| 1106 | 1106 | }); |
| 1107 | 1107 | |
| 1108 | 1108 | $this->bots = $bots; |
@@ -1217,7 +1217,7 @@ discard block |
||
| 1217 | 1217 | |
| 1218 | 1218 | if ($info['all'] > 1) { |
| 1219 | 1219 | // Number of seconds/days between first and last edit. |
| 1220 | - $secs = $info['last']->getTimestamp() - $info['first']->getTimestamp(); |
|
| 1220 | + $secs = $info['last']->getTimestamp()-$info['first']->getTimestamp(); |
|
| 1221 | 1221 | $days = $secs / (60 * 60 * 24); |
| 1222 | 1222 | |
| 1223 | 1223 | // Average time between edits (in days). |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | |
| 1237 | 1237 | // First sort editors array by the amount of text they added. |
| 1238 | 1238 | $topTenEditorsByAdded = $this->editors; |
| 1239 | - uasort($topTenEditorsByAdded, function ($a, $b) { |
|
| 1239 | + uasort($topTenEditorsByAdded, function($a, $b) { |
|
| 1240 | 1240 | if ($a['added'] === $b['added']) { |
| 1241 | 1241 | return 0; |
| 1242 | 1242 | } |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | |
| 1246 | 1246 | // Then build a new array of top 10 editors by added text, |
| 1247 | 1247 | // in the data structure needed for the chart. |
| 1248 | - $this->topTenEditorsByAdded = array_map(function ($editor) { |
|
| 1248 | + $this->topTenEditorsByAdded = array_map(function($editor) { |
|
| 1249 | 1249 | $added = $this->editors[$editor]['added']; |
| 1250 | 1250 | return [ |
| 1251 | 1251 | 'label' => $editor, |
@@ -1399,7 +1399,7 @@ discard block |
||
| 1399 | 1399 | |
| 1400 | 1400 | $refs = $crawler->filter('#mw-content-text .reference'); |
| 1401 | 1401 | $refContent = []; |
| 1402 | - $refs->each(function ($ref) use (&$refContent) { |
|
| 1402 | + $refs->each(function($ref) use (&$refContent) { |
|
| 1403 | 1403 | $refContent[] = $ref->text(); |
| 1404 | 1404 | }); |
| 1405 | 1405 | $uniqueRefs = count(array_unique($refContent)); |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | $totalChars = 0; |
| 1428 | 1428 | $totalWords = 0; |
| 1429 | 1429 | $paragraphs = $crawler->filter($selector); |
| 1430 | - $paragraphs->each(function ($node) use (&$totalChars, &$totalWords) { |
|
| 1430 | + $paragraphs->each(function($node) use (&$totalChars, &$totalWords) { |
|
| 1431 | 1431 | $text = preg_replace('/\[\d+\]/', '', trim($node->text())); |
| 1432 | 1432 | $totalChars += strlen($text); |
| 1433 | 1433 | $totalWords += count(explode(' ', $text)); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $hasPageAssessments = $this->isLabs() && $project->hasPageAssessments() && $namespace === 0; |
| 48 | 48 | $paTable = $this->getTableName($project->getDatabaseName(), 'page_assessments'); |
| 49 | 49 | $paSelect = $hasPageAssessments |
| 50 | - ? ", ( |
|
| 50 | + ? ", ( |
|
| 51 | 51 | SELECT pa_class |
| 52 | 52 | FROM $paTable |
| 53 | 53 | WHERE pa_page_id = page_id |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $hasPageAssessments = $this->isLabs() && $project->hasPageAssessments(); |
| 99 | 99 | $pageAssessmentsTable = $this->getTableName($project->getDatabaseName(), 'page_assessments'); |
| 100 | 100 | $paSelect = $hasPageAssessments |
| 101 | - ? ", ( |
|
| 101 | + ? ", ( |
|
| 102 | 102 | SELECT pa_class |
| 103 | 103 | FROM $pageAssessmentsTable |
| 104 | 104 | WHERE pa_page_id = e.page_id |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | { |
| 164 | 164 | $firstDateTime = $this->topEdits[0]->getTimestamp(); |
| 165 | 165 | $lastDateTime = end($this->topEdits)->getTimestamp(); |
| 166 | - $secs = $firstDateTime->getTimestamp() - $lastDateTime->getTimestamp(); |
|
| 166 | + $secs = $firstDateTime->getTimestamp()-$lastDateTime->getTimestamp(); |
|
| 167 | 167 | $days = $secs / (60 * 60 * 24); |
| 168 | 168 | return $days / count($this->topEdits); |
| 169 | 169 | } |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | $displayTitles = $this->getDisplayTitles($pages); |
| 298 | 298 | |
| 299 | 299 | foreach ($pages as $page) { |
| 300 | - $nsId = (int) $page['page_namespace']; |
|
| 301 | - $nsTitle = $nsId > 0 ? $this->project->getNamespaces()[$page['page_namespace']] . ':' : ''; |
|
| 302 | - $pageTitle = $nsTitle . $page['page_title']; |
|
| 300 | + $nsId = (int)$page['page_namespace']; |
|
| 301 | + $nsTitle = $nsId > 0 ? $this->project->getNamespaces()[$page['page_namespace']].':' : ''; |
|
| 302 | + $pageTitle = $nsTitle.$page['page_title']; |
|
| 303 | 303 | $page['displaytitle'] = $displayTitles[$pageTitle]; |
| 304 | 304 | |
| 305 | 305 | // $page['page_title'] is retained without the namespace |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | $namespaces = $this->project->getNamespaces(); |
| 327 | 327 | |
| 328 | 328 | // First extract page titles including namespace. |
| 329 | - $pageTitles = array_map(function ($page) use ($namespaces) { |
|
| 329 | + $pageTitles = array_map(function($page) use ($namespaces) { |
|
| 330 | 330 | // If non-mainspace, prepend namespace to the titles. |
| 331 | 331 | $ns = $page['page_namespace']; |
| 332 | - $nsTitle = $ns > 0 ? $namespaces[$page['page_namespace']] . ':' : ''; |
|
| 333 | - return $nsTitle . $page['page_title']; |
|
| 332 | + $nsTitle = $ns > 0 ? $namespaces[$page['page_namespace']].':' : ''; |
|
| 333 | + return $nsTitle.$page['page_title']; |
|
| 334 | 334 | }, $topPages); |
| 335 | 335 | |
| 336 | 336 | return $this->getRepository()->getDisplayTitles($this->project, $pageTitles); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $datesConditions = $this->getDateConditions($start, $end); |
| 30 | 30 | |
| 31 | 31 | $sql = "SELECT COUNT(DISTINCT(rev_id)) AS count, rev_user_text AS username, ug_group AS current |
| 32 | - FROM " . $project->getTableName('revision') . " |
|
| 32 | + FROM " . $project->getTableName('revision')." |
|
| 33 | 33 | LEFT JOIN $userGroupsTable ON rev_user = ug_user |
| 34 | 34 | LEFT JOIN $userFormerGroupsTable ON rev_user = ufg_user |
| 35 | 35 | WHERE rev_page = :pageId AND (ug_group = 'bot' OR ufg_group = 'bot') $datesConditions |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $sql = "SELECT log_action, log_type, log_timestamp AS 'timestamp' |
| 58 | 58 | FROM $loggingTable |
| 59 | - WHERE log_namespace = '" . $page->getNamespace() . "' |
|
| 59 | + WHERE log_namespace = '".$page->getNamespace()."' |
|
| 60 | 60 | AND log_title = :title AND log_timestamp > 1 $datesConditions |
| 61 | 61 | AND log_type IN ('delete', 'move', 'protect', 'stable')"; |
| 62 | 62 | $title = str_replace(' ', '_', $page->getTitle()); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $projectLang = $page->getProject()->getLang(); |
| 81 | 81 | |
| 82 | - $url = "https://api.wikiwho.net/$projectLang/api/v1.0.0-beta/rev_content/" . |
|
| 82 | + $url = "https://api.wikiwho.net/$projectLang/api/v1.0.0-beta/rev_content/". |
|
| 83 | 83 | "$title/?o_rev_id=false&editor=true&token_id=false&out=false&in=false"; |
| 84 | 84 | |
| 85 | 85 | $res = $client->request('GET', $url, ['http_errors' => false]); |
@@ -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 | /** |
| 71 | 71 | * Rate limiting will not apply to these actions |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $cacheItem = $cache->getItem($cacheKey); |
| 92 | 92 | |
| 93 | 93 | // If increment value already in cache, or start with 1. |
| 94 | - $count = $cacheItem->isHit() ? (int) $cacheItem->get() + 1 : 1; |
|
| 94 | + $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1; |
|
| 95 | 95 | |
| 96 | 96 | // Check if limit has been exceeded, and if so, throw an error. |
| 97 | 97 | if ($count > $this->rateLimit) { |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | // Log the denied request |
| 144 | 144 | $logger = $this->container->get('monolog.logger.rate_limit'); |
| 145 | 145 | $logger->info( |
| 146 | - "<URI>: " . $request->getRequestUri() . |
|
| 147 | - ($logComment != '' ? "\t<Reason>: $logComment" : '') . |
|
| 148 | - "\t<User agent>: " . $request->headers->get('User-Agent') |
|
| 146 | + "<URI>: ".$request->getRequestUri(). |
|
| 147 | + ($logComment != '' ? "\t<Reason>: $logComment" : ''). |
|
| 148 | + "\t<User agent>: ".$request->headers->get('User-Agent') |
|
| 149 | 149 | ); |
| 150 | 150 | |
| 151 | 151 | throw new TooManyRequestsHttpException(600, 'error-rate-limit', null, $this->rateDuration); |