mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-17038 - truncate overlength varchar fields before attempting to insert
Author: Peter Bulmer <peter.bulmer@catalyst.net.nz>
This commit is contained in:
parent
6da155db35
commit
9dbc81ef23
@ -886,7 +886,8 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
|
||||
unset($logEntryObj->username);
|
||||
|
||||
$insertok = $DB->insert_record('mnet_log', $logEntryObj, false);
|
||||
$logEntryObj = $this->trim_logline($logEntryObj);
|
||||
$insertok = $DB->insert_record('mnet_log', $logEntryObj, false);
|
||||
|
||||
if ($insertok) {
|
||||
$MNET_REMOTE_CLIENT->last_log_id = $logEntryObj->remoteid;
|
||||
@ -1341,6 +1342,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…
x
Reference in New Issue
Block a user