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

Improve the readonly session debugging message

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      1) setup a default moodle with default MUC (ie session cache in the session)

      2) Tail the logs

      3) Download and run MDL-68608-readonly-debugging.php

      4) Confirm there is no errors or exceptions

       

      5) Enable debugging reload MDL-68608-readonly-debugging.php

      6) Confirm that you do see errors showing what would have been written in the session

      7) Turn off debugging, and set this in config.php:

      $CFG->enable_read_only_sessions_debug = true;

      8) Confirm that you do see errors showing what would have been written in the session

      9) Now fully turn on readonly sessions:

      $CFG->enable_read_only_sessions = true;

       10) Confirm in the logs you see the name of the script which cause the error when it tried to write to the session which is readonly

      11) Confirm in the logs you can see not only the fact that cachestore_session was changed in the session but which component (ie core/coursecat)

      12) Confirm that it also threw an exception and the UI shows the red error box hard kills the whole site

      13) Confirm this exception is shown on all pages, eg home / dashboard

       

      Example logs:

       This page /MDL-68608-readonly-debugging.php started a read-only session but writes were detected.
      The following SESSION params were either added, or were updated.
      SESSION key: cachestore_session
      SESSION key: random
      PHP Fatal error: Uncaught moodle_exception: error/The session store can not be in the session when enable_read_only_sessions is enabled. Found these caches in the session:
      core/coursecat in /var/www/moodle.local/lib/classes/session/manager.php:718
      Stack trace:
      #0 /var/www/moodle.local/lib/classes/shutdown_manager.php(181): core
      session
      manager::write_close()
      #1 [internal function]: core_shutdown_manager::shutdown_handler()
      #2 {main}
      thrown in /var/www/moodle.local/lib/classes/session/manager.php on line 718

      Show
      1) setup a default moodle with default MUC (ie session cache in the session) 2) Tail the logs 3) Download and run  MDL-68608 -readonly-debugging.php 4) Confirm there is no errors or exceptions   5) Enable debugging reload  MDL-68608 -readonly-debugging.php 6) Confirm that you do see errors showing what would have been written in the session 7) Turn off debugging, and set this in config.php: $CFG->enable_read_only_sessions_debug = true; 8) Confirm that you do see errors showing what would have been written in the session 9) Now fully turn on readonly sessions: $CFG->enable_read_only_sessions = true;  10) Confirm in the logs you see the name of the script which cause the error when it tried to write to the session which is readonly 11) Confirm in the logs you can see not only the fact that cachestore_session was changed in the session but which component (ie core/coursecat) 12) Confirm that it also threw an exception and the UI shows the red error box hard kills the whole site 13) Confirm this exception is shown on all pages, eg home / dashboard   Example logs:  This page / MDL-68608 -readonly-debugging.php started a read-only session but writes were detected. The following SESSION params were either added, or were updated. SESSION key: cachestore_session SESSION key: random PHP Fatal error: Uncaught moodle_exception: error/The session store can not be in the session when enable_read_only_sessions is enabled. Found these caches in the session: core/coursecat in /var/www/moodle.local/lib/classes/session/manager.php:718 Stack trace: #0 /var/www/moodle.local/lib/classes/shutdown_manager.php(181): core session manager::write_close() #1 [internal function] : core_shutdown_manager::shutdown_handler() #2 {main} thrown in /var/www/moodle.local/lib/classes/session/manager.php on line 718
    • Affected Branches:
      MOODLE_311_STABLE, MOODLE_400_STABLE
    • Pull Master Branch:
      MDL-68608-improve-readonly-debugging

      Description

      The warning when a page mutates the session doesn't quite have enough info in it to be useful. In theory every instance of this debugging call should end up as a new tracker so we want the error message to be reasonably verbose and contain everything we need to create a tracker and trace down the problem.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              brendanheywood Brendan Heywood
              Reporter:
              brendanheywood Brendan Heywood
              Peer reviewer:
              Dmitrii Metelkin
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated: