Skip to content

Commit

Permalink
MDL-17038 - truncate overlength varchar fields before attempting to i…
Browse files Browse the repository at this point in the history
…nsert

Signed-off-by: Peter Bulmer <peter.bulmer@catalyst.net.nz>


Author: Peter Bulmer <peter.bulmer@catalyst.net.nz>
  • Loading branch information
peterbulmer committed Oct 30, 2008
1 parent d5942d6 commit 0095949
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions auth/mnet/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ function refresh_log($array) {

unset($logEntryObj->username);

$logEntryObj = $this->trim_logline($logEntryObj);
$insertok = insert_record('mnet_log', addslashes_object($logEntryObj), false);

if ($insertok) {
Expand Down Expand Up @@ -1352,6 +1353,25 @@ function logoutpage_hook() {
}
}

/**
* 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;
}


}

?>

0 comments on commit 0095949

Please sign in to comment.