mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 03:46:42 +02:00
MDL-17038 - truncate overlength varchar fields before attempting to insert
Signed-off-by: Peter Bulmer <peter.bulmer@catalyst.net.nz> Author: Peter Bulmer <peter.bulmer@catalyst.net.nz>
This commit is contained in:
parent
c5caa7199d
commit
48fd1cf621
1 changed files with 20 additions and 0 deletions
|
@ -885,6 +885,7 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||||
|
|
||||||
unset($logEntryObj->username);
|
unset($logEntryObj->username);
|
||||||
|
|
||||||
|
$logEntryObj = $this->trim_logline($logEntryObj);
|
||||||
$insertok = insert_record('mnet_log', addslashes_object($logEntryObj), false);
|
$insertok = insert_record('mnet_log', addslashes_object($logEntryObj), false);
|
||||||
|
|
||||||
if ($insertok) {
|
if ($insertok) {
|
||||||
|
@ -1351,6 +1352,25 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trims a log line from mnet peer to limit each part to a length which can be stored in our DB
|
||||||
|
*
|
||||||
|
* @param object $logline The log information to be trimmed
|
||||||
|
* @return object The passed logline object trimmed to not exceed storable limits
|
||||||
|
*/
|
||||||
|
function trim_logline ($logline) {
|
||||||
|
$limits = array('ip' => 15, 'coursename' => 40, 'module' => 20, 'action' => 40,
|
||||||
|
'url' => 255);
|
||||||
|
foreach ($limits as $property => $limit) {
|
||||||
|
if (isset($logline->$property)) {
|
||||||
|
$logline->$property = substr($logline->$property, 0, $limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $logline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue