Index: lib/datalib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/datalib.php,v retrieving revision 1.439.2.16 diff -u -r1.439.2.16 datalib.php --- lib/datalib.php 26 Feb 2008 21:51:16 -0000 1.439.2.16 +++ lib/datalib.php 13 Mar 2008 13:16:34 -0000 @@ -1878,6 +1878,25 @@ $url = html_entity_decode($url); // for php < 4.3.0 this is defined in moodlelib.php } + // Restrict length of log lines to the space actually available in the + // database so that it doesn't cause a DB error. Log a warning so that + // developers can avoid doing things which are likely to cause this on a + // routine basis. + if(!empty($info) && strlen($info)>255) { + $info=substr($info,0,252).'...'; + debugging('Warning: logged very long info'); + } + // Note: Unlike $info, URL appears to be already slashed before this function + // is called. Since database limits are for the data before slashes, we need + // to remove them... + $url=stripslashes($url); + // If the 100 field size is changed, also need to alter print_log in course/lib.php + if(!empty($url) && strlen($url)>100) { + $url=substr($url,0,97).'...'; + debugging('Warning: logged very long URL'); + } + $url=addslashes($url); + if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++; $PERF->logwrites++;}; if ($CFG->type = 'oci8po') { Index: course/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/course/lib.php,v retrieving revision 1.538.2.26 diff -u -r1.538.2.26 lib.php --- course/lib.php 29 Feb 2008 08:40:40 -0000 1.538.2.26 +++ course/lib.php 13 Mar 2008 13:16:33 -0000 @@ -295,6 +295,10 @@ //Filter log->info $log->info = format_string($log->info); + + // If $log->url has been trimmed short by the db size restriction + // code in add_to_log, keep a note so we don't add a link to a broken url + $brokenurl=(strlen($log->url)==100 && substr($log->url,97)=='...'); $log->url = strip_tags(urldecode($log->url)); // Some XSS protection $log->info = strip_tags(urldecode($log->info)); // Some XSS protection @@ -320,7 +324,12 @@ echo " wwwroot/user/view.php?id={$log->userid}&course={$log->course}\">$fullname\n"; echo "\n"; echo "\n"; - link_to_popup_window( make_log_url($log->module,$log->url), 'fromloglive',"$log->module $log->action", 440, 700); + $displayaction="$log->module $log->action"; + if($brokenurl) { + echo $displayaction; + } else { + link_to_popup_window( make_log_url($log->module,$log->url), 'fromloglive',$displayaction, 440, 700); + } echo "\n";; echo "{$log->info}\n"; echo "\n";