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

task 'stats_cron_task' stuck in infinite loop

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      It is covered by a unit test and too difficult to test manually.

      Set up

      1. Initialise PHPUnit test environment (docs).
      2. Pull the patch from the repository (docs).

      Test before patch

      1. Check out the commit that includes the unit test (change the commit hash if needed). 

        git checkout 1ea9bc21304     
        

      2. Run the unit test.

        vendor/bin/phpunit --filter "/(::test_statslib_get_base_weekly)( .*)?$/" core_statslib_testcase lib/tests/statslib_test.php
        

      3. Confirm that the first test fails (it includes a date affected by a DST).

      Test after applying the patch

      1. Check out the commit that includes the patch.

        git checkout MDL-58596-master  
        

      2. Run the unit test (see above).
      3. Confirm that all the tests pass.
      Show
      It is covered by a unit test and too difficult to test manually. Set up Initialise PHPUnit test environment ( docs ). Pull the patch from the repository ( docs ). Test before patch Check out the commit that includes the unit test (change the commit hash if needed).  git checkout 1ea9bc21304 Run the unit test. vendor /bin/phpunit --filter "/(::test_statslib_get_base_weekly)( .*)?$/" core_statslib_testcase lib /tests/statslib_test .php Confirm that the first test fails (it includes a date affected by a DST). Test after applying the patch Check out the commit that includes the patch. git checkout MDL-58596-master Run the unit test (see above). Confirm that all the tests pass.
    • Affected Branches:
      MOODLE_32_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE, MOODLE_36_STABLE
    • Pull from Repository:
    • Pull 3.5 Branch:
    • Pull 3.6 Branch:
    • Pull Master Branch:
      MDL-58596-master

      Description

      When the statistics cron component (stats_cron_task)  "first runs" it tries to gather all the previous weeks statistics by calculating the beginning/ending of each week's begin/end in unixtime

      But it miscalculates the beginning/end of the weeks that contain Daylight Savings Time changes.

      In my case, it caused an infinite loop.

      The cause: in the file 'statslib.php' the function 'stats_get_next_week' blindly adds 1 weeks worth of seconds. But, if the week contains a  DST change, it should +/- an 3600 seconds to prevent looping.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                14/Jan/19

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 30 minutes
                2h 30m