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

core\lock\lock::__destruct hides potentially thrown exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 3.3.1
    • Tasks
    • None
    • MOODLE_33_STABLE

      I believe there is a bug on this line https://github.com/moodle/moodle/blob/v3.3.1/lib/classes/lock/lock.php#L114 as the condition defined('PHPUNIT_TEST') always evaluates to true. As a result, if there is a thrown exception and we get to this destructor, the details of the original exception are swallowed and replaced with this new exception thrown here.

      This actually happened to me when there was an exception thrown by the locking subsystem which was not caught - whole story at https://github.com/catalyst/moodle-tool_lockstats/issues/19

      Was it intended to throw this exception only in unit tests? So that badly written code that does not release the lock, would be identified without affecting the functionality in production?

      Or was it intended to throw the exception everywhere but in unit tests?

      Maybe it would be better to simply call debugging()?

            Unassigned Unassigned
            mudrd8mz David Mudrák (@mudrd8mz)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.