Drift in statistics_day_timestamp yields inaccurate daycounts.

Created on 17 July 2009, over 15 years ago
Updated 30 April 2024, 7 months ago

The code below causes the statistics day timestamp to drift by the time it takes to execute the db operation to clear all the daycount fields. A small site will never notice but with 10's of thousands of nodes it becomes noticeable.

  if ((time() - $statistics_timestamp) >= 86400) {
    // Reset day counts.
    db_query('UPDATE {node_counter} SET daycount = 0');
    variable_set('statistics_day_timestamp', time());
  }

It should say something like

  if ((time() - $statistics_timestamp) >= 86400) {
    // Reset day counts.
    db_query('UPDATE {node_counter} SET daycount = 0');
    variable_set('statistics_day_timestamp', $statistics_timestamp+86400);
  }
πŸ› Bug report
Status

Needs work

Version

1.0

Component
StatisticsΒ  β†’

Last updated about 22 hours ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States jpp

Live updates comments and jobs are added and updated live.
  • Needs backport to D6

    After being applied to the 7.x branch, it should be considered for backport to the 6.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024