Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-17038 - truncate overlength varchar fields before attempting to i…

…nsert

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


Author: Peter Bulmer <peter.bulmer@catalyst.net.nz>
  • Loading branch information...
commit 48fd1cf62172a63b5832bf6dd28084b606c28b6e 1 parent c5caa71
peterbulmer authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 auth/mnet/auth.php
View
20 auth/mnet/auth.php
@@ -885,6 +885,7 @@ function refresh_log($array) {
unset($logEntryObj->username);
+ $logEntryObj = $this->trim_logline($logEntryObj);
$insertok = insert_record('mnet_log', addslashes_object($logEntryObj), false);
if ($insertok) {
@@ -1351,6 +1352,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;
+ }
+
+
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.