Completed
Pull Request — master (#13)
by
unknown
02:25
created
web/app_dev.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
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.');
Please login to merge, or discard this patch.
xtools_utilities/nonautomated_edits_parse.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
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");
Please login to merge, or discard this patch.
src/AppBundle/Controller/TopEditsController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
                 'username' => $username,
49 49
             ]);
50 50
         } elseif ($project != "") {
51
-            return $this->redirectToRoute("TopEditsResults", [ 'project'=>$project ]);
51
+            return $this->redirectToRoute("TopEditsResults", ['project'=>$project]);
52 52
         }
53 53
 
54 54
         // replace this example code with whatever you need
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $editData = $conn->executeQuery($query, $params)->fetchAll();
101 101
 
102 102
         // Get page info about these 100 pages, so we can use their display title.
103
-        $titles = array_map(function ($e) {
103
+        $titles = array_map(function($e) {
104 104
             return $e['page_title'];
105 105
         }, $editData);
106 106
         /** @var ApiHelper $apiHelper */
Please login to merge, or discard this patch.
src/AppBundle/Controller/AdminScoreController.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
src/AppBundle/Controller/PagesController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                 'username' => $username,
57 57
             ]);
58 58
         } elseif ($projectQuery != "") {
59
-            return $this->redirectToRoute("PagesProject", [ 'project'=>$projectQuery ]);
59
+            return $this->redirectToRoute("PagesProject", ['project'=>$projectQuery]);
60 60
         }
61 61
 
62 62
         // Retrieving the global groups, using the ApiHelper class
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
         }
219 219
 
220 220
         if ($total < 1) {
221
-            $this->addFlash("notice", [ "noresult", $username ]);
222
-            return $this->redirectToRoute("PagesProject", [ "project"=>$project ]);
221
+            $this->addFlash("notice", ["noresult", $username]);
222
+            return $this->redirectToRoute("PagesProject", ["project"=>$project]);
223 223
         }
224 224
 
225 225
         ksort($pagesArray);
Please login to merge, or discard this patch.
src/AppBundle/Controller/SimpleEditCounterController.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,
Please login to merge, or discard this patch.
src/AppBundle/Helper/EditCounterHelper.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     public function getUserId($usernameOrIp)
40 40
     {
41 41
         // Use cache if possible.
42
-        $cacheItem = $this->cache->getItem('ec.usernameOrIp.' . $usernameOrIp);
42
+        $cacheItem = $this->cache->getItem('ec.usernameOrIp.'.$usernameOrIp);
43 43
         if ($cacheItem->isHit()) {
44 44
             return $cacheItem->get();
45 45
         }
@@ -106,24 +106,24 @@  discard block
 block discarded – undo
106 106
         }
107 107
 
108 108
         $revisionCounts = array_combine(
109
-            array_map(function ($e) {
109
+            array_map(function($e) {
110 110
                 return $e['source'];
111 111
             }, $results),
112
-            array_map(function ($e) {
112
+            array_map(function($e) {
113 113
                 return $e['value'];
114 114
             }, $results)
115 115
         );
116 116
 
117 117
         // Count the number of days, accounting for when there's only one edit.
118
-        $editingTimeInSeconds = ceil($revisionCounts['last'] - $revisionCounts['first']);
119
-        $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds/(60*60*24) : 1;
118
+        $editingTimeInSeconds = ceil($revisionCounts['last']-$revisionCounts['first']);
119
+        $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds / (60 * 60 * 24) : 1;
120 120
 
121 121
         // Format the first and last dates.
122 122
         $revisionCounts['first'] = date('Y-m-d H:i', strtotime($revisionCounts['first']));
123 123
         $revisionCounts['last'] = date('Y-m-d H:i', strtotime($revisionCounts['last']));
124 124
 
125 125
         // Sum deleted and live to make the total.
126
-        $revisionCounts['total'] = $revisionCounts['deleted'] + $revisionCounts['live'];
126
+        $revisionCounts['total'] = $revisionCounts['deleted']+$revisionCounts['live'];
127 127
         
128 128
         // Calculate the average number of live edits per day.
129 129
         $revisionCounts['avg_per_day'] = round(
@@ -160,16 +160,16 @@  discard block
 block discarded – undo
160 160
         $results = $resultQuery->fetchAll();
161 161
 
162 162
         $pageCounts = array_combine(
163
-            array_map(function ($e) {
163
+            array_map(function($e) {
164 164
                 return $e['source'];
165 165
             }, $results),
166
-            array_map(function ($e) {
166
+            array_map(function($e) {
167 167
                 return $e['value'];
168 168
             }, $results)
169 169
         );
170 170
 
171 171
         // Total created.
172
-        $pageCounts['created'] = $pageCounts['created-live'] + $pageCounts['created-deleted'];
172
+        $pageCounts['created'] = $pageCounts['created-live']+$pageCounts['created-deleted'];
173 173
 
174 174
         // Calculate the average number of edits per page.
175 175
         $pageCounts['edits_per_page'] = 0;
@@ -196,17 +196,17 @@  discard block
 block discarded – undo
196 196
         $resultQuery->execute();
197 197
         $results = $resultQuery->fetchAll();
198 198
         $logCounts = 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
         // Make sure there is some value for each of the wanted counts.
208 208
         $requiredCounts = [
209
-            'thanks-thank', 'review-approve', 'patrol-patrol','block-block', 'block-unblock',
209
+            'thanks-thank', 'review-approve', 'patrol-patrol', 'block-block', 'block-unblock',
210 210
             'protect-protect', 'protect-unprotect', 'delete-delete', 'delete-revision',
211 211
             'delete-restore', 'import-import', 'upload-upload', 'upload-overwrite',
212 212
         ];
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
         }
218 218
 
219 219
         // Merge approvals together.
220
-        $logCounts['review-approve'] = $logCounts['review-approve'] +
221
-            (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
222
-            (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
220
+        $logCounts['review-approve'] = $logCounts['review-approve']+
221
+            (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
222
+            (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
223 223
             (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
224 224
 
225 225
         // Add Commons upload count, if applicable.
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     public function getNamespaceTotals($userId)
245 245
     {
246 246
         $sql = "SELECT page_namespace, count(rev_id) AS total
247
-            FROM ".$this->labsHelper->getTable('revision') ." r
247
+            FROM ".$this->labsHelper->getTable('revision')." r
248 248
                 JOIN ".$this->labsHelper->getTable('page')." p on r.rev_page = p.page_id
249 249
             WHERE r.rev_user = :id GROUP BY page_namespace";
250 250
         $resultQuery = $this->replicas->prepare($sql);
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
         $resultQuery->execute();
253 253
         $results = $resultQuery->fetchAll();
254 254
         $namespaceTotals = array_combine(
255
-            array_map(function ($e) {
255
+            array_map(function($e) {
256 256
                 return $e['page_namespace'];
257 257
             }, $results),
258
-            array_map(function ($e) {
258
+            array_map(function($e) {
259 259
                 return $e['total'];
260 260
             }, $results)
261 261
         );
Please login to merge, or discard this patch.
src/AppBundle/Helper/LabsHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             // Create the query we're going to run against the meta database
62 62
             $wikiQuery = $this->client->createQueryBuilder();
63 63
             $wikiQuery
64
-                ->select([ 'dbName', 'name', 'url' ])
64
+                ->select(['dbName', 'name', 'url'])
65 65
                 ->from('wiki')
66 66
                 ->where($wikiQuery->expr()->eq('dbname', ':project'))
67 67
                 // The meta database will have the project's URL stored as https://en.wikipedia.org
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         $this->dbName = $dbName;
100 100
         $this->url = $url;
101 101
 
102
-        return [ 'dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url ];
102
+        return ['dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url];
103 103
     }
104 104
 
105 105
     /**
Please login to merge, or discard this patch.
src/AppBundle/Helper/PageviewsHelper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.