Moodle

stats_cron_monthly infinite loop for negative timezones

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: 1.6.1
  • Fix Version/s: None
  • Component/s: Libraries
  • Labels:
    None
  • Environment:
    All
  • Database:
    Any
  • Affected Branches:
    MOODLE_16_STABLE

Description

Description:

When running admin/cron.php with stats generation, the while in stats_cron_monthly() in lib/statslib.php runs into a infinite loop and fills up the server space with junks in database (stats_monthly table).

Affected setup:

This bug affects servers in negative timezones with the correct local time set, but choose a negative GMT number in the timezone option under Variables in Administration.

(bug does not affect negative timezone servers with timezone set to Server's local time)

Action:

running admin/cron.php (manually or scheduled)

Coniditions:

  • The stats_daily, stats_weekly, and stats_monthly tables do not contain any previously created data (empty tables).
  • Administration/Configuration/Variables/Interface/timezone is set to a negative GMT.
  • Administration/Configuration/Variables/Statistics/enablestats is set to Yes
  • Administration/Configuration/Variables/Statistics/statsfirstrun is set to start at a time that's in the last month
  • Administration/Configuration/Variables/Statistics/statsmaxruntime is set to Until complete (might not have an effect on this bug?)

Furthur observation:

In stats_getdate() in lib/statslib.php, after the

$time += intval((float)$timezone * HOURSECS);

timezone adjustment, any negative timezone will be returned as an earlier time. This leads back to the while infinite loop in stats_cron_monthly():

while ($monthend >= $nextmonthend) {

Since nextmonthend is alwasys the same and smaller than monthend, this loop never ends. Server CPU goes 100%, database gets filled with junk data, all kind of wonderful things happen.

Suggested Fix:

  • User: the timezone option should be set to Server's local time if the server is not using GMT(0).
  • Moodle: better description for the timezone option? additional server timezone check in statslib?

Issue Links

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: