@@ -11,8 +11,8 @@ |
||
11 | 11 | { |
12 | 12 | $this->createTable(self::TABLE, [ |
13 | 13 | 'id' => Schema::TYPE_PK, |
14 | - 'entry_id' => Schema::TYPE_INTEGER . ' NOT NULL', |
|
15 | - 'type' => Schema::TYPE_STRING . '(255) NOT NULL', |
|
14 | + 'entry_id' => Schema::TYPE_INTEGER.' NOT NULL', |
|
15 | + 'type' => Schema::TYPE_STRING.'(255) NOT NULL', |
|
16 | 16 | 'data' => Schema::TYPE_BINARY, |
17 | 17 | ], ($this->db->driverName === 'mysql' ? 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB' : null)); |
18 | 18 |
@@ -12,15 +12,15 @@ discard block |
||
12 | 12 | $driver = $this->db->driverName; |
13 | 13 | $this->createTable(self::TABLE, [ |
14 | 14 | 'id' => Schema::TYPE_PK, |
15 | - 'entry_id' => Schema::TYPE_INTEGER . ' NOT NULL', |
|
16 | - 'created' => Schema::TYPE_DATETIME . ' NOT NULL', |
|
17 | - 'message' => Schema::TYPE_TEXT . ' NOT NULL', |
|
18 | - 'code' => Schema::TYPE_INTEGER . " DEFAULT '0'", |
|
19 | - 'file' => Schema::TYPE_STRING . '(512)', |
|
20 | - 'line' => Schema::TYPE_INTEGER , |
|
15 | + 'entry_id' => Schema::TYPE_INTEGER.' NOT NULL', |
|
16 | + 'created' => Schema::TYPE_DATETIME.' NOT NULL', |
|
17 | + 'message' => Schema::TYPE_TEXT.' NOT NULL', |
|
18 | + 'code' => Schema::TYPE_INTEGER." DEFAULT '0'", |
|
19 | + 'file' => Schema::TYPE_STRING.'(512)', |
|
20 | + 'line' => Schema::TYPE_INTEGER, |
|
21 | 21 | 'trace' => Schema::TYPE_BINARY, |
22 | - 'hash' => Schema::TYPE_STRING . '(32)', |
|
23 | - 'emailed' => Schema::TYPE_BOOLEAN . " NOT NULL DEFAULT '0'", |
|
22 | + 'hash' => Schema::TYPE_STRING.'(32)', |
|
23 | + 'emailed' => Schema::TYPE_BOOLEAN." NOT NULL DEFAULT '0'", |
|
24 | 24 | ], ($driver === 'mysql' ? 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB' : null)); |
25 | 25 | |
26 | 26 | if ($driver != 'sqlite') { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | // Issue #122: Specified key was too long; max key length is 767 bytes - http://stackoverflow.com/q/1814532/50158 |
31 | - $this->createIndex('idx_file', self::TABLE, ['file' . ($driver === 'mysql' ? '(180)' : '')]); |
|
31 | + $this->createIndex('idx_file', self::TABLE, ['file'.($driver === 'mysql' ? '(180)' : '')]); |
|
32 | 32 | $this->createIndex('idx_emailed', self::TABLE, ['emailed']); |
33 | 33 | } |
34 | 34 |
@@ -12,14 +12,14 @@ |
||
12 | 12 | $this->createTable(self::TABLE, [ |
13 | 13 | 'id' => Schema::TYPE_PK, |
14 | 14 | 'entry_id' => Schema::TYPE_INTEGER, |
15 | - 'user_id' => Schema::TYPE_INTEGER . ' NULL', |
|
16 | - 'action' => Schema::TYPE_STRING . ' NOT NULL', |
|
17 | - 'model' => Schema::TYPE_STRING . ' NOT NULL', |
|
18 | - 'model_id' => Schema::TYPE_STRING . ' NOT NULL', |
|
15 | + 'user_id' => Schema::TYPE_INTEGER.' NULL', |
|
16 | + 'action' => Schema::TYPE_STRING.' NOT NULL', |
|
17 | + 'model' => Schema::TYPE_STRING.' NOT NULL', |
|
18 | + 'model_id' => Schema::TYPE_STRING.' NOT NULL', |
|
19 | 19 | 'field' => Schema::TYPE_STRING, |
20 | 20 | 'old_value' => Schema::TYPE_TEXT, |
21 | 21 | 'new_value' => Schema::TYPE_TEXT, |
22 | - 'created' => Schema::TYPE_DATETIME . ' NOT NULL', |
|
22 | + 'created' => Schema::TYPE_DATETIME.' NOT NULL', |
|
23 | 23 | ], ($this->db->driverName === 'mysql' ? 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB' : null)); |
24 | 24 | |
25 | 25 | if ($this->db->driverName != 'sqlite') { |
@@ -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(); |
@@ -106,9 +106,9 @@ |
||
106 | 106 | if (strlen($this->user_id)) { |
107 | 107 | if (!is_numeric($userId) && $callback = Audit::getInstance()->userFilterCallback) { |
108 | 108 | $userId = call_user_func($callback, $userId); |
109 | + } else { |
|
110 | + $userId = intval($this->user_id) ?: 0; |
|
109 | 111 | } |
110 | - else |
|
111 | - $userId = intval($this->user_id) ?: 0; |
|
112 | 112 | } |
113 | 113 | $query->andFilterWhere(['user_id' => $userId]); |
114 | 114 | } |
@@ -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); |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This model allows for storing of javascript logging entries linked to a specific audit entry |
|
4 | - */ |
|
3 | + * This model allows for storing of javascript logging entries linked to a specific audit entry |
|
4 | + */ |
|
5 | 5 | |
6 | 6 | namespace bedezign\yii2\audit\models; |
7 | 7 |