@@ -31,8 +31,7 @@ |
||
31 | 31 | try |
32 | 32 | { |
33 | 33 | (new \Joomla\StatsServer\Kernel\WebKernel)->run(); |
34 | -} |
|
35 | -catch (\Throwable $throwable) |
|
34 | +} catch (\Throwable $throwable) |
|
36 | 35 | { |
37 | 36 | error_log($throwable); |
38 | 37 |
@@ -70,8 +70,7 @@ discard block |
||
70 | 70 | try |
71 | 71 | { |
72 | 72 | $this->migrations->migrateDatabase($version); |
73 | - } |
|
74 | - catch (\Exception $exception) |
|
73 | + } catch (\Exception $exception) |
|
75 | 74 | { |
76 | 75 | $this->logger->critical( |
77 | 76 | 'Error migrating database', |
@@ -86,8 +85,7 @@ discard block |
||
86 | 85 | if ($version) |
87 | 86 | { |
88 | 87 | $message = sprintf('Database migrated to version "%s".', $version); |
89 | - } |
|
90 | - else |
|
88 | + } else |
|
91 | 89 | { |
92 | 90 | $message = 'Database migrated to latest version.'; |
93 | 91 | } |
@@ -64,12 +64,10 @@ |
||
64 | 64 | if (!$status->tableExists) |
65 | 65 | { |
66 | 66 | $symfonyStyle->comment('The migrations table does not exist, run the "database:migrate" command to set up the database.'); |
67 | - } |
|
68 | - elseif ($status->latest) |
|
67 | + } elseif ($status->latest) |
|
69 | 68 | { |
70 | 69 | $symfonyStyle->success('Your database is up-to-date.'); |
71 | - } |
|
72 | - else |
|
70 | + } else |
|
73 | 71 | { |
74 | 72 | $symfonyStyle->comment(sprintf('Your database is not up-to-date. You are missing %d migration(s).', $status->missingMigrations)); |
75 | 73 |
@@ -102,8 +102,7 @@ |
||
102 | 102 | if ($this->recent) |
103 | 103 | { |
104 | 104 | $items = $this->repository->getRecentlyUpdatedItems(); |
105 | - } |
|
106 | - else |
|
105 | + } else |
|
107 | 106 | { |
108 | 107 | $items = $this->repository->getItems($this->source); |
109 | 108 | } |
@@ -82,8 +82,7 @@ |
||
82 | 82 | try |
83 | 83 | { |
84 | 84 | $this->analytics->sendPageview(); |
85 | - } |
|
86 | - catch (\Exception $e) |
|
85 | + } catch (\Exception $e) |
|
87 | 86 | { |
88 | 87 | // Log the error for reference |
89 | 88 | $this->logger->error( |
@@ -132,8 +132,7 @@ |
||
132 | 132 | if ($recordExists) |
133 | 133 | { |
134 | 134 | $this->db->updateObject('#__jstats', $data, ['unique_id']); |
135 | - } |
|
136 | - else |
|
135 | + } else |
|
137 | 136 | { |
138 | 137 | $this->db->insertObject('#__jstats', $data, ['unique_id']); |
139 | 138 | } |
@@ -140,45 +140,45 @@ |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | |
143 | - /** |
|
144 | - * Loads the recently updated statistics data from the database. |
|
145 | - * |
|
146 | - * Updated within a timeframe, submit a pull request for a different behavior. |
|
147 | - * |
|
148 | - * @return array An array containing the response data |
|
149 | - */ |
|
150 | - public function getTimeframeUpdatedItems(int $timeframe = 0, string $showColumn = ''): array |
|
151 | - { |
|
152 | - $return = []; |
|
153 | - $columns = self::ALLOWED_SOURCES; |
|
154 | - if ($showColumn !== '') { |
|
155 | - // The column should exist in the table and be part of the API |
|
156 | - if (!\in_array($showColumn, self::ALLOWED_SOURCES)) { |
|
157 | - throw new \InvalidArgumentException('An invalid data source was requested.', 404); |
|
158 | - } |
|
159 | - |
|
160 | - $columns = [$showColumn]; |
|
161 | - } |
|
162 | - |
|
163 | - foreach ($columns as $column) { |
|
164 | - if (\in_array($column, ['cms_php_version', 'db_type_version'])) { |
|
165 | - throw new \InvalidArgumentException('An invalid data source was requested.', 404); |
|
166 | - } |
|
167 | - $return[$column] = $this->db->setQuery( |
|
168 | - $this->db->getQuery(true) |
|
169 | - ->select($column) |
|
170 | - ->select('COUNT(' . $column . ') AS count') |
|
171 | - ->from('(SELECT * FROM ' . $this->db->quoteName('#__jstats') . ' WHERE modified > DATE_SUB(NOW(), INTERVAL ' . $this->db->quote($timeframe) .' DAY)) AS tmptable') |
|
172 | - ->group($column) |
|
173 | - )->loadAssocList(); |
|
174 | - } |
|
175 | - |
|
176 | - if ($showColumn !== '') { |
|
177 | - return $return[$showColumn]; |
|
178 | - } |
|
179 | - |
|
180 | - return $return; |
|
181 | - } |
|
143 | + /** |
|
144 | + * Loads the recently updated statistics data from the database. |
|
145 | + * |
|
146 | + * Updated within a timeframe, submit a pull request for a different behavior. |
|
147 | + * |
|
148 | + * @return array An array containing the response data |
|
149 | + */ |
|
150 | + public function getTimeframeUpdatedItems(int $timeframe = 0, string $showColumn = ''): array |
|
151 | + { |
|
152 | + $return = []; |
|
153 | + $columns = self::ALLOWED_SOURCES; |
|
154 | + if ($showColumn !== '') { |
|
155 | + // The column should exist in the table and be part of the API |
|
156 | + if (!\in_array($showColumn, self::ALLOWED_SOURCES)) { |
|
157 | + throw new \InvalidArgumentException('An invalid data source was requested.', 404); |
|
158 | + } |
|
159 | + |
|
160 | + $columns = [$showColumn]; |
|
161 | + } |
|
162 | + |
|
163 | + foreach ($columns as $column) { |
|
164 | + if (\in_array($column, ['cms_php_version', 'db_type_version'])) { |
|
165 | + throw new \InvalidArgumentException('An invalid data source was requested.', 404); |
|
166 | + } |
|
167 | + $return[$column] = $this->db->setQuery( |
|
168 | + $this->db->getQuery(true) |
|
169 | + ->select($column) |
|
170 | + ->select('COUNT(' . $column . ') AS count') |
|
171 | + ->from('(SELECT * FROM ' . $this->db->quoteName('#__jstats') . ' WHERE modified > DATE_SUB(NOW(), INTERVAL ' . $this->db->quote($timeframe) .' DAY)) AS tmptable') |
|
172 | + ->group($column) |
|
173 | + )->loadAssocList(); |
|
174 | + } |
|
175 | + |
|
176 | + if ($showColumn !== '') { |
|
177 | + return $return[$showColumn]; |
|
178 | + } |
|
179 | + |
|
180 | + return $return; |
|
181 | + } |
|
182 | 182 | /** |
183 | 183 | * Saves the given data. |
184 | 184 | * |
@@ -188,8 +188,7 @@ discard block |
||
188 | 188 | try |
189 | 189 | { |
190 | 190 | $validVersions = json_decode($this->filesystem->read('joomla.json'), true); |
191 | - } |
|
192 | - catch (FileNotFoundException $exception) |
|
191 | + } catch (FileNotFoundException $exception) |
|
193 | 192 | { |
194 | 193 | throw new \RuntimeException('Missing Joomla! release listing', 500, $exception); |
195 | 194 | } |
@@ -248,8 +247,7 @@ discard block |
||
248 | 247 | try |
249 | 248 | { |
250 | 249 | $validVersions = json_decode($this->filesystem->read('php.json'), true); |
251 | - } |
|
252 | - catch (FileNotFoundException $exception) |
|
250 | + } catch (FileNotFoundException $exception) |
|
253 | 251 | { |
254 | 252 | throw new \RuntimeException('Missing PHP release listing', 500, $exception); |
255 | 253 | } |
@@ -64,8 +64,7 @@ discard block |
||
64 | 64 | ->select('version') |
65 | 65 | ->from('#__migrations') |
66 | 66 | )->loadColumn(); |
67 | - } |
|
68 | - catch (ExecutionFailureException | PrepareStatementFailureException $exception) |
|
67 | + } catch (ExecutionFailureException | PrepareStatementFailureException $exception) |
|
69 | 68 | { |
70 | 69 | // On PDO we're checking "42S02, 1146, Table 'XXX.#__migrations' doesn't exist" |
71 | 70 | if (strpos($exception->getMessage(), "migrations' doesn't exist") === false) |
@@ -132,8 +131,7 @@ discard block |
||
132 | 131 | ->select('version') |
133 | 132 | ->from('#__migrations') |
134 | 133 | )->loadColumn(); |
135 | - } |
|
136 | - catch (ExecutionFailureException | PrepareStatementFailureException $exception) |
|
134 | + } catch (ExecutionFailureException | PrepareStatementFailureException $exception) |
|
137 | 135 | { |
138 | 136 | // If the table does not exist, we can still try to run migrations |
139 | 137 | if (strpos($exception->getMessage(), "migrations' doesn't exist") === false) |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | try |
58 | 58 | { |
59 | 59 | $processHelper->mustRun($output, new Process(['git', 'pull'], APPROOT)); |
60 | - } |
|
61 | - catch (ProcessFailedException $e) |
|
60 | + } catch (ProcessFailedException $e) |
|
62 | 61 | { |
63 | 62 | $this->getApplication()->getLogger()->error('Could not execute `git pull`', ['exception' => $e]); |
64 | 63 | |
@@ -73,8 +72,7 @@ discard block |
||
73 | 72 | try |
74 | 73 | { |
75 | 74 | $processHelper->mustRun($output, new Process(['composer', 'install', '--no-dev', '-o', '-a'], APPROOT)); |
76 | - } |
|
77 | - catch (ProcessFailedException $e) |
|
75 | + } catch (ProcessFailedException $e) |
|
78 | 76 | { |
79 | 77 | $this->getApplication()->getLogger()->error('Could not update Composer resources', ['exception' => $e]); |
80 | 78 |