This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
In the system log sometimes I can see messages like this:
PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'url' at row 1 in /var/www/asm.ru/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105
Probably the field 'url' has no mutator to cut very long url before saving. Current core version 447
\modules\system\models\RequestLog.php
There's no mutator value for the url column. The maximum size is 191. Who can I write to fix the bug? :)
I can add event for now, but it would be better if developers fix the bug in kernel
Solution:
RequestLog::extend(function($model) {
$model->bindEvent('model.beforeSave', function() use ($model) {
$model->attributes['url'] = mb_substr(trim($model->attributes['url']), 0, 191);
});
});
But it's temporary. Before updates :)
Last updated
@glower, can you test if the following patch solves the issue? I'll submit a PR to october core if it does.
diff --git a/modules/system/models/RequestLog.php b/modules/system/models/RequestLog.php
index ab93b119..615edca6 100644
--- a/modules/system/models/RequestLog.php
+++ b/modules/system/models/RequestLog.php
@@ -62,4 +62,9 @@ class RequestLog extends Model
return $record;
}
+
+ public function beforeModelSave()
+ {
+ $this->attributes['url'] = mb_substr(trim($model->attributes['url']), 0, 191);
+ }
}
october/modules/system/models/RequestLog.php
line 45
'url' => substr(Request::fullUrl(), 0, 255),
change to
'url' => substr(Request::fullUrl(), 0, 191),
Last updated
https://github.com/octobercms/october/pull/4287
This has been merged into the develop branch.
1-9 of 9