@@ -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, |
@@ -119,7 +119,7 @@ |
||
119 | 119 | // for batch inserts the same way. This code adds a number of literals instead of the actual values |
120 | 120 | // so that they can be bound right before insert and still get escaped correctly |
121 | 121 | foreach ($batchData as $type => $data) { |
122 | - $param = ':data_' . str_replace('/', '_', $type); |
|
122 | + $param = ':data_'.str_replace('/', '_', $type); |
|
123 | 123 | $rows[] = [$this->id, $type, $date, new Expression($param)]; |
124 | 124 | $params[$param] = [Helper::serialize($data, $compact), \PDO::PARAM_LOB]; |
125 | 125 | } |
@@ -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 | } |
@@ -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]) |
@@ -57,8 +57,9 @@ |
||
57 | 57 | |
58 | 58 | // adjust the query by adding the filters |
59 | 59 | $userId = $this->user_id; |
60 | - if (strlen($this->user_id)) |
|
61 | - $userId = intval($this->user_id) ?: 0; |
|
60 | + if (strlen($this->user_id)) { |
|
61 | + $userId = intval($this->user_id) ?: 0; |
|
62 | + } |
|
62 | 63 | |
63 | 64 | $query->andFilterWhere(['id' => $this->id]); |
64 | 65 | $query->andFilterWhere(['entry_id' => $this->entry_id]); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | return $entry ? $this->log($entry->id, $e) : null; |
30 | 30 | }); |
31 | 31 | |
32 | - $this->module->registerFunction('errorMessage', function ($message, $code = 0, $file = '', $line = 0, $trace = []) { |
|
32 | + $this->module->registerFunction('errorMessage', function($message, $code = 0, $file = '', $line = 0, $trace = []) { |
|
33 | 33 | $entry = $this->module->getEntry(true); |
34 | 34 | return $entry ? $this->logMessage($entry->id, $message, $code, $file, $line, $trace) : null; |
35 | 35 | }); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $error->file = $exception->getFile(); |
62 | 62 | $error->line = $exception->getLine(); |
63 | 63 | $error->trace = Helper::cleanupTrace($exception->getTrace()); |
64 | - $error->hash = Helper::hash($error->message . $error->file . $error->line); |
|
64 | + $error->hash = Helper::hash($error->message.$error->file.$error->line); |
|
65 | 65 | |
66 | 66 | $this->_exceptions[] = $exceptionId; |
67 | 67 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $error->file = $file; |
89 | 89 | $error->line = $line; |
90 | 90 | $error->trace = Helper::cleanupTrace($trace); |
91 | - $error->hash = Helper::hash($error->message . $error->file . $error->line); |
|
91 | + $error->hash = Helper::hash($error->message.$error->file.$error->line); |
|
92 | 92 | return $error->save(false) ? $error : null; |
93 | 93 | } |
94 | 94 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getLabel() |
115 | 115 | { |
116 | - return $this->getName() . ' <small>(' . count($this->_model->linkedErrors) . ')</small>'; |
|
116 | + return $this->getName().' <small>('.count($this->_model->linkedErrors).')</small>'; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -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 | ]); |
@@ -36,7 +36,7 @@ |
||
36 | 36 | */ |
37 | 37 | public function getLabel() |
38 | 38 | { |
39 | - return $this->getName() . ' <small>(' . count($this->data) . ')</small>'; |
|
39 | + return $this->getName().' <small>('.count($this->data).')</small>'; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,8 +46,9 @@ |
||
46 | 46 | public function trackData($type, $data) |
47 | 47 | { |
48 | 48 | $this->module->getEntry(true); |
49 | - if (!is_array($this->data)) |
|
50 | - $this->data = []; |
|
49 | + if (!is_array($this->data)) { |
|
50 | + $this->data = []; |
|
51 | + } |
|
51 | 52 | |
52 | 53 | $this->data[] = ['type' => $type, 'data' => $data]; |
53 | 54 | } |