@@ -11,11 +11,11 @@ |
||
| 11 | 11 | { |
| 12 | 12 | $this->createTable(self::TABLE, [ |
| 13 | 13 | 'id' => Schema::TYPE_PK, |
| 14 | - 'entry_id' => Schema::TYPE_INTEGER . ' NOT NULL', |
|
| 15 | - 'created' => Schema::TYPE_DATETIME . ' NOT NULL', |
|
| 16 | - 'type' => Schema::TYPE_STRING . '(20) NOT NULL', |
|
| 17 | - 'message' => Schema::TYPE_TEXT . ' NOT NULL', |
|
| 18 | - 'origin' => Schema::TYPE_STRING . '(512)', |
|
| 14 | + 'entry_id' => Schema::TYPE_INTEGER.' NOT NULL', |
|
| 15 | + 'created' => Schema::TYPE_DATETIME.' NOT NULL', |
|
| 16 | + 'type' => Schema::TYPE_STRING.'(20) NOT NULL', |
|
| 17 | + 'message' => Schema::TYPE_TEXT.' NOT NULL', |
|
| 18 | + 'origin' => Schema::TYPE_STRING.'(512)', |
|
| 19 | 19 | 'data' => Schema::TYPE_BINARY, |
| 20 | 20 | ], $this->db->driverName === 'mysql' ? 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB' : null); |
| 21 | 21 | |
@@ -11,9 +11,9 @@ |
||
| 11 | 11 | { |
| 12 | 12 | $this->createTable(self::TABLE, [ |
| 13 | 13 | 'id' => Schema::TYPE_PK, |
| 14 | - 'entry_id' => Schema::TYPE_INTEGER . ' NOT NULL', |
|
| 15 | - 'created' => Schema::TYPE_DATETIME . ' NOT NULL', |
|
| 16 | - 'successful' => Schema::TYPE_INTEGER . ' NOT NULL', |
|
| 14 | + 'entry_id' => Schema::TYPE_INTEGER.' NOT NULL', |
|
| 15 | + 'created' => Schema::TYPE_DATETIME.' NOT NULL', |
|
| 16 | + 'successful' => Schema::TYPE_INTEGER.' NOT NULL', |
|
| 17 | 17 | 'from' => Schema::TYPE_STRING, |
| 18 | 18 | 'to' => Schema::TYPE_STRING, |
| 19 | 19 | 'reply' => Schema::TYPE_STRING, |
@@ -50,8 +50,9 @@ |
||
| 50 | 50 | public static function create($initialise = true) |
| 51 | 51 | { |
| 52 | 52 | $entry = new static; |
| 53 | - if ($initialise) |
|
| 54 | - $entry->record(); |
|
| 53 | + if ($initialise) { |
|
| 54 | + $entry->record(); |
|
| 55 | + } |
|
| 55 | 56 | |
| 56 | 57 | return $entry; |
| 57 | 58 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | // for batch inserts the same way. This code adds a number of literals instead of the actual values |
| 123 | 123 | // so that they can be bound right before insert and still get escaped correctly |
| 124 | 124 | foreach ($batchData as $type => $data) { |
| 125 | - $param = ':data_' . str_replace('/', '_', $type); |
|
| 125 | + $param = ':data_'.str_replace('/', '_', $type); |
|
| 126 | 126 | $rows[] = [$this->id, $type, $date, new Expression($param)]; |
| 127 | 127 | $params[$param] = [Helper::serialize($data, $compact), \PDO::PARAM_LOB]; |
| 128 | 128 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | if ($this->getRequestMethodIsCli()) { |
| 233 | 233 | $route = $this->route; |
| 234 | 234 | } else { |
| 235 | - $route = '/' . $this->route; |
|
| 235 | + $route = '/'.$this->route; |
|
| 236 | 236 | } |
| 237 | 237 | return Url::to([$route ?: '/'], 'https'); |
| 238 | 238 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | static public function routeFilter() |
| 78 | 78 | { |
| 79 | - $routes = AuditEntry::getDb()->cache(function () { |
|
| 79 | + $routes = AuditEntry::getDb()->cache(function() { |
|
| 80 | 80 | return AuditEntry::find()->distinct(true) |
| 81 | 81 | ->select('route')->where(['is not', 'route', null]) |
| 82 | 82 | ->groupBy('route')->orderBy('route ASC')->column(); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | static public function methodFilter() |
| 91 | 91 | { |
| 92 | - $methods = AuditEntry::getDb()->cache(function () { |
|
| 92 | + $methods = AuditEntry::getDb()->cache(function() { |
|
| 93 | 93 | return AuditEntry::find()->distinct(true) |
| 94 | 94 | ->select('request_method')->where(['is not', 'request_method', null]) |
| 95 | 95 | ->groupBy('request_method')->orderBy('request_method ASC')->column(); |
@@ -93,7 +93,7 @@ |
||
| 93 | 93 | */ |
| 94 | 94 | static protected function filterData() |
| 95 | 95 | { |
| 96 | - return AuditEntry::getDb()->cache(function () { |
|
| 96 | + return AuditEntry::getDb()->cache(function() { |
|
| 97 | 97 | return AuditError::find()->distinct(true) |
| 98 | 98 | ->select(['hash', 'message', 'file'])->asArray()->all(); |
| 99 | 99 | }, 30); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function typeFilter() |
| 70 | 70 | { |
| 71 | - $types = AuditJavascript::getDb()->cache(function () { |
|
| 71 | + $types = AuditJavascript::getDb()->cache(function() { |
|
| 72 | 72 | return AuditJavascript::find()->distinct(true) |
| 73 | 73 | ->select('type') |
| 74 | 74 | ->where(['entry_id' => $this->entry_id]) |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function originFilter() |
| 85 | 85 | { |
| 86 | - $origin = AuditJavascript::getDb()->cache(function () { |
|
| 86 | + $origin = AuditJavascript::getDb()->cache(function() { |
|
| 87 | 87 | return AuditJavascript::find()->distinct(true) |
| 88 | 88 | ->select('origin') |
| 89 | 89 | ->where(['entry_id' => $this->entry_id]) |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function getLabel() |
| 63 | 63 | { |
| 64 | - return $this->getName() . ' <small>(' . count($this->data) . ')</small>'; |
|
| 64 | + return $this->getName().' <small>('.count($this->data).')</small>'; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | if ($this->content) |
| 140 | - $this->data[$id]['content']= curl_multi_getcontent($handle); |
|
| 140 | + $this->data[$id]['content'] = curl_multi_getcontent($handle); |
|
| 141 | 141 | |
| 142 | 142 | // Cleanup empty things |
| 143 | 143 | $this->data[$id] = array_filter($this->data[$id]); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | if (!is_resource($resource)) |
| 209 | 209 | return false; |
| 210 | 210 | |
| 211 | - $parts = explode('#', (string)$resource); |
|
| 211 | + $parts = explode('#', (string) $resource); |
|
| 212 | 212 | return array_pop($parts); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -96,19 +96,22 @@ discard block |
||
| 96 | 96 | curl_setopt($handle, CURLOPT_URL, $url); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ($postData) |
|
| 100 | - $this->data[$id]['post'] = $postData; |
|
| 99 | + if ($postData) { |
|
| 100 | + $this->data[$id]['post'] = $postData; |
|
| 101 | + } |
|
| 101 | 102 | |
| 102 | - if ($this->headers) |
|
| 103 | - curl_setopt($handle, CURLOPT_HEADERFUNCTION, [$this, 'captureHeader']); |
|
| 103 | + if ($this->headers) { |
|
| 104 | + curl_setopt($handle, CURLOPT_HEADERFUNCTION, [$this, 'captureHeader']); |
|
| 105 | + } |
|
| 104 | 106 | |
| 105 | 107 | if ($this->log) { |
| 106 | 108 | curl_setopt($handle, CURLOPT_VERBOSE, true); |
| 107 | 109 | curl_setopt($handle, CURLOPT_STDERR, $this->_logHandles[$id] = fopen('php://temp', 'rw+')); |
| 108 | 110 | } |
| 109 | 111 | |
| 110 | - if ($this->content) |
|
| 111 | - curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1); |
|
| 112 | + if ($this->content) { |
|
| 113 | + curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1); |
|
| 114 | + } |
|
| 112 | 115 | |
| 113 | 116 | return true; |
| 114 | 117 | } |
@@ -136,8 +139,9 @@ discard block |
||
| 136 | 139 | unset($this->_logHandles[$id]); |
| 137 | 140 | } |
| 138 | 141 | |
| 139 | - if ($this->content) |
|
| 140 | - $this->data[$id]['content']= curl_multi_getcontent($handle); |
|
| 142 | + if ($this->content) { |
|
| 143 | + $this->data[$id]['content']= curl_multi_getcontent($handle); |
|
| 144 | + } |
|
| 141 | 145 | |
| 142 | 146 | // Cleanup empty things |
| 143 | 147 | $this->data[$id] = array_filter($this->data[$id]); |
@@ -192,8 +196,9 @@ discard block |
||
| 192 | 196 | public function captureHeader($handle, $header) |
| 193 | 197 | { |
| 194 | 198 | $id = $this->id($handle); |
| 195 | - if (!isset($this->data[$id]['headers'])) |
|
| 196 | - $this->data[$id]['headers'] = []; |
|
| 199 | + if (!isset($this->data[$id]['headers'])) { |
|
| 200 | + $this->data[$id]['headers'] = []; |
|
| 201 | + } |
|
| 197 | 202 | |
| 198 | 203 | $this->data[$id]['headers'][] = $header; |
| 199 | 204 | return strlen($header); |
@@ -205,8 +210,9 @@ discard block |
||
| 205 | 210 | */ |
| 206 | 211 | protected function id($resource) |
| 207 | 212 | { |
| 208 | - if (!is_resource($resource)) |
|
| 209 | - return false; |
|
| 213 | + if (!is_resource($resource)) { |
|
| 214 | + return false; |
|
| 215 | + } |
|
| 210 | 216 | |
| 211 | 217 | $parts = explode('#', (string)$resource); |
| 212 | 218 | return array_pop($parts); |
@@ -29,8 +29,8 @@ |
||
| 29 | 29 | { |
| 30 | 30 | $timings = $this->calculateTimings(); |
| 31 | 31 | $queryCount = count($timings); |
| 32 | - $queryTime = number_format($this->getTotalQueryTime($timings) * 1000) . ' ms'; |
|
| 33 | - return $this->getName() . ' <small>(' . $queryCount . ' / ' . $queryTime . ')</small>'; |
|
| 32 | + $queryTime = number_format($this->getTotalQueryTime($timings) * 1000).' ms'; |
|
| 33 | + return $this->getName().' <small>('.$queryCount.' / '.$queryTime.')</small>'; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -47,12 +47,14 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | // Only log each exception once |
| 49 | 49 | $exceptionId = spl_object_hash($exception); |
| 50 | - if (in_array($exceptionId, $this->_exceptions)) |
|
| 51 | - return true; |
|
| 50 | + if (in_array($exceptionId, $this->_exceptions)) { |
|
| 51 | + return true; |
|
| 52 | + } |
|
| 52 | 53 | |
| 53 | 54 | // If this is a follow up exception, make sure to log the base exception first |
| 54 | - if ($exception->getPrevious()) |
|
| 55 | - $this->log($entry_id, $exception->getPrevious()); |
|
| 55 | + if ($exception->getPrevious()) { |
|
| 56 | + $this->log($entry_id, $exception->getPrevious()); |
|
| 57 | + } |
|
| 56 | 58 | |
| 57 | 59 | $error = new AuditError(); |
| 58 | 60 | $error->entry_id = $entry_id; |
@@ -165,8 +167,9 @@ discard block |
||
| 165 | 167 | public function cleanup($maxAge = null) |
| 166 | 168 | { |
| 167 | 169 | $maxAge = $maxAge !== null ? $maxAge : $this->maxAge; |
| 168 | - if ($maxAge === null) |
|
| 169 | - return false; |
|
| 170 | + if ($maxAge === null) { |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 170 | 173 | return AuditError::deleteAll([ |
| 171 | 174 | '<=', 'created', date('Y-m-d 23:59:59', strtotime("-$maxAge days")) |
| 172 | 175 | ]); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | return $entry ? $this->log($entry->id, $e) : null; |
| 32 | 32 | }); |
| 33 | 33 | |
| 34 | - $this->module->registerFunction('errorMessage', function ($message, $code = 0, $file = '', $line = 0, $trace = []) { |
|
| 34 | + $this->module->registerFunction('errorMessage', function($message, $code = 0, $file = '', $line = 0, $trace = []) { |
|
| 35 | 35 | $entry = $this->module->getEntry(true); |
| 36 | 36 | return $entry ? $this->logMessage($entry->id, $message, $code, $file, $line, $trace) : null; |
| 37 | 37 | }); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $error->file = $exception->getFile(); |
| 64 | 64 | $error->line = $exception->getLine(); |
| 65 | 65 | $error->trace = Helper::cleanupTrace($exception->getTrace()); |
| 66 | - $error->hash = Helper::hash($error->message . $error->file . $error->line); |
|
| 66 | + $error->hash = Helper::hash($error->message.$error->file.$error->line); |
|
| 67 | 67 | |
| 68 | 68 | $this->_exceptions[] = $exceptionId; |
| 69 | 69 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $error->file = $file; |
| 91 | 91 | $error->line = $line; |
| 92 | 92 | $error->trace = Helper::cleanupTrace($trace); |
| 93 | - $error->hash = Helper::hash($error->message . $error->file . $error->line); |
|
| 93 | + $error->hash = Helper::hash($error->message.$error->file.$error->line); |
|
| 94 | 94 | return $error->save(false) ? $error : null; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function getLabel() |
| 117 | 117 | { |
| 118 | - return $this->getName() . ' <small>(' . $this->_model->getLinkedErrors()->count() . ')</small>'; |
|
| 118 | + return $this->getName().' <small>('.$this->_model->getLinkedErrors()->count().')</small>'; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |