Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-13761

Issues with add_to_log URL field

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.9
    • Fix Version/s: None
    • Component/s: Libraries
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      The log table url field is 100 characters. This can be a bit limiting in some instances where log entries may include text strings, such as filenames. (The easiest way to cause a problem with this is to make a wiki page with a 100-character name.)

      There are three related problems:

      1) Calling add_to_log with something longer than the url field results in an SQL error, and sends an email to the admin suggesting the database might have run out of disk space. While this behaviour is pretty cool, I don't think 'some stupid module tried to log a really long url' is serious enough for an admin email My suggested fix is:

      a) Check length is under the limited for 'url' and 'info' parameters (only ones which are likely to potentially depend on user input) and trim to limited length, with '...', if needed.

      b) If this trim happens, show debugging() info so that developers might notice they are logging something that can get too long.

      c) In log view, if url field ends with ..., don't treat it as a link (as it won't work!).

      2) The phpdoc for add_to_log is unclear as to the value of the URL field. It might seem obvious for developers to assume that it is, in fact, a fully qualified URL; however in fact it doesn't have to be, and the precise value for it depends on the type of plugin (sigh). It's difficult to track this down without following through a variety of code in log view, and when you do find out how it works, it's complicated.

      a) Change make_log_url in course/lib.php so that it supports block_, format_ prefixes in $module (if you passed in block_whatever and url frog.php at present, it would change the URL to /mod/block_whatever/frog.php - not helpful) and so that [apart from the existing exceptions] it is possible to begin your URL with / to mean 'start at $CFG->wwwroot' whatever the $module. The intent would be to make this function return exactly the same as it does now for all uses of the current function that return a correct url, but make it more consistent for future use and support blocks, course formats.

      b) Make phpdoc for add_to_log reflect this.

      3) 100 characters is too short in some cases especially if full URLs are logged. (are they supposed to be? maybe it's relative to $CFG->wwwroot, but this isn't clear in the phpdoc, this should also be clarified). I think the limit should be increased to 255. Could this cause problems for some databases, or is that change ok?

      I haven't done the code for this yet, if it is ok I will do it for moodle 1.9.1 or just for 2.0, let me know which. (I'll remember to mark only the relevant version fixed as per martin's request in developer meeting!)

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  2 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: