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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 3.3.1
    • Fix Version/s: None
    • Component/s: Tasks
    • Labels:
      None
    • Affected Branches:
      MOODLE_33_STABLE

      Description

      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()?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                mudrd8mz David Mudrák (@mudrd8mz)
                Participants:
                Component watchers:
                Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: