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

Minor improvements to add_to_log()

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9.1
    • Component/s: General
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      Was playing with MDL-14257 when I saw some things that could be slightly improved in the add_to_log() current incarnation:

      1) The update of lastip and lastaccess (user table): The query es executed ALWAYS, no matter if it finally ends updating the record or no. Proposal: perform the ( $timenow - lastaccess > 60) condition in PHP (using the $USER->lastaccess) variable. And, of course updating it if the record is updated.

      2) The update of timeaccess (user_lastaccess table): We always perform one query + one update, no matter if the update finally changes anything or no. Proposal: Fetch also the timeaccess in the query and then perform the ($timenow - timeaccess > 60) condition in PHP.

      That way we'll save TWO updates per add_to_log() call, that is, indeed, a lot!

      My only concern is about to update $USER->lastaccess continuosly. Not sure if if affects recent activity and so (I guess no and lastlogin is used instead). But better to confirm it.

      Ciao

      PS: Feel free to reassign to me if you think it's ok and you want me to implement.

        Attachments

        1. datalib.php.patch
          4 kB
        2. last_access6.patch
          8 kB
        3. last_access7.patch
          11 kB

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                15/May/08