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

task 'stats_cron_task' stuck in infinite loop

    XMLWordPrintable

Details

    • MOODLE_32_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
    • MOODLE_35_STABLE, MOODLE_36_STABLE
    • MDL-58596-master
    • 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.

    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

        1. MDL-58596.jpg
          39 kB
          Anna Carissa Sadia
        2. stats_cron_output.txt
          63 kB
          Jordan Tomkinson

        Activity

          People

            vmdef Victor Déniz Falcón
            jodell James O'Dell
            Damyon Wiese Damyon Wiese
            Andrew Lyons Andrew Lyons
            Anna Carissa Sadia Anna Carissa Sadia
            David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              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