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

Stop lock destruction throwing a new exception

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.1, 3.5.5
    • Fix Version/s: 3.5.6, 3.6.4
    • Component/s: Analytics, Other
    • Labels:
    • Testing Instructions:
      Hide

      Note that you will have to edit .php files to test this issue.

      Prerequisites

      1. Install https://github.com/dmonllao/moodle-local_testanalytics

      Test 1

      1. Run the command below and remember the id of the Binary model.

          
        php admin/tool/analytics/cli/evaluate_model.php --list
        

      2. Run the command below using the id of the Binary model.

        php admin/tool/analytics/cli/evaluate_model.php --reuse-prev-analysed=0 --modelid=BINARY_MODEL_ID
        

      3. You SHOULD NOT see any error. You can finish the CLI command by typing 'none' or just Ctrl + C

      Test 2

      1. Open analytics/classes/calculable.php file and add the following line at the beginning of the 'add_sample_data' method:

        throw new \coding_exception('TEST 2 MDL-63906');
        

      2. Run the command below using the id of the Binary model.

        php admin/tool/analytics/cli/evaluate_model.php --reuse-prev-analysed=0 --modelid=BINARY_MODEL_ID
        

      3. You SHOULD get an exception with 'TEST 2 MDL-63906' message and you SHOULD NOT see any reference to a lock not being released correctly
      4. Reset analytics/classes/calculable.php to its original state

      Test 3

      1. Open analytics/classes/local/time_splitting/base.php file and add the following line at the beginning of the 'calculate' method:

        throw new \coding_exception('TEST 3 MDL-63906');
        

      2. Run the command below using the id of the Binary model.

        php admin/tool/analytics/cli/evaluate_model.php --reuse-prev-analysed=0 --modelid=BINARY_MODEL_ID
        

      3. You SHOULD get an exception with 'TEST 3 MDL-63906' message and you SHOULD NOT see any reference to a lock not being released correctly
      4. Reset analytics/classes/local/time_splitting/base.php to its original state

      Test 4

      1. Open analytics/classes/local/analyser/base.php file and add the following line at the beginning of the 'add_model_metadata' method:

        double([111]);
        

      2. Run the command below using the id of the Binary model.

        php admin/tool/analytics/cli/evaluate_model.php --reuse-prev-analysed=0 --modelid=BINARY_MODEL_ID
        

      3. You SHOULD get an exception with 'Exception - Call to undefined function core_analytics\local\analyser\double()' message and you SHOULD NOT see any reference to a lock not being released correctly
      4. Reset analytics/classes/local/analyser/base.php to its original state

      Note: At the end of the test, revert the changes that you made:

      git reset --hard
      

      Show
      Note that you will have to edit .php files to test this issue. Prerequisites Install https://github.com/dmonllao/moodle-local_testanalytics Test 1 Run the command below and remember the id of the Binary model. php admin/tool/analytics/cli/evaluate_model.php --list Run the command below using the id of the Binary model. php admin/tool/analytics/cli/evaluate_model.php --reuse-prev-analysed=0 --modelid=BINARY_MODEL_ID You SHOULD NOT see any error. You can finish the CLI command by typing 'none' or just Ctrl + C Test 2 Open analytics/classes/calculable.php file and add the following line at the beginning of the 'add_sample_data' method: throw new \coding_exception('TEST 2 MDL-63906'); Run the command below using the id of the Binary model. php admin/tool/analytics/cli/evaluate_model.php --reuse-prev-analysed=0 --modelid=BINARY_MODEL_ID You SHOULD get an exception with 'TEST 2 MDL-63906 ' message and you SHOULD NOT see any reference to a lock not being released correctly Reset analytics/classes/calculable.php to its original state Test 3 Open analytics/classes/local/time_splitting/base.php file and add the following line at the beginning of the 'calculate' method: throw new \coding_exception('TEST 3 MDL-63906'); Run the command below using the id of the Binary model. php admin/tool/analytics/cli/evaluate_model.php --reuse-prev-analysed=0 --modelid=BINARY_MODEL_ID You SHOULD get an exception with 'TEST 3 MDL-63906 ' message and you SHOULD NOT see any reference to a lock not being released correctly Reset analytics/classes/local/time_splitting/base.php to its original state Test 4 Open analytics/classes/local/analyser/base.php file and add the following line at the beginning of the 'add_model_metadata' method: double([111]); Run the command below using the id of the Binary model. php admin/tool/analytics/cli/evaluate_model.php --reuse-prev-analysed=0 --modelid=BINARY_MODEL_ID You SHOULD get an exception with 'Exception - Call to undefined function core_analytics\local\analyser\double()' message and you SHOULD NOT see any reference to a lock not being released correctly Reset analytics/classes/local/analyser/base.php to its original state Note: At the end of the test, revert the changes that you made: git reset --hard
    • Affected Branches:
      MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE, MOODLE_36_STABLE
    • Pull from Repository:
    • Pull 3.5 Branch:
    • Pull 3.6 Branch:
    • Pull Master Branch:
      MDL-63906_master

      Description

      If the __destruct() function in lock.php is invoked because an exception has been thrown elsewhere then it shouldn't throw one itself when a lock hasn't been released.

      The exception thrown is this circumstance is inaccurate/misleading and just masks the original cause of any problem.

      This can affect any component but I selected Analytics below because it is an issue with that component and the 'Collapsed Topic' course format that has brought this problem to light for us.

       

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                13/May/19

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h