Skip to main content

Rebuild jobs

Two xf-rebuild:* commands run as standard batch jobs with the usual rebuild ergonomics: progress reporting, --batch tuning, and --resume after interruption.

php cmd.php xf-rebuild:mc-dm-stats [-b 500] [--resume]
php cmd.php xf-rebuild:mc-dm-integrity [-b 500] [--resume] [--repair]

Common options:

OptionDescription
-b, --batch=NBatch size per job step (default 500)
--resumeResume the previous run instead of starting fresh
--log-queriesEnable the query logger for the run

xf-rebuild:mc-dm-stats

Recomputes denormalized counters on every download row and refreshes the statistics cache used by the analytics widgets and per-download dashboards.

Run this after:

  • A bulk import that bypassed the entity layer.
  • Direct SQL manipulation of xf_mc_dm_download_view or xf_mc_dm_download_log.
  • A counter mismatch reported by mc-dm:health-check (download_counters probe in 0.11+).
php cmd.php xf-rebuild:mc-dm-stats
Rebuilding... [MC] Downloads Manager: download statistics (45)

The number in parentheses is the total download row count to process.

xf-rebuild:mc-dm-integrity

Reads every stored file via the addon's Flysystem mount, computes SHA-256, and compares the result against the file_hash column on the xf_mc_dm_file row.

php cmd.php xf-rebuild:mc-dm-integrity # report only
php cmd.php xf-rebuild:mc-dm-integrity --repair # rewrite stored hash on mismatch
OptionDescription
--repairRewrite file_hash from the actual file contents on mismatch. Default is report-only

Mismatches are written to the server error log with the file ID, stored hash, and computed hash. Without --repair the database is not modified.

Use --repair only when you trust the file contents over the stored hash — for example, after a hash-algorithm migration or when you have just restored files from a backup that the database does not know about. Repairing a hash for a file that has been tampered with locks in the tampered state.

The job streams files via readStream() so memory usage stays flat regardless of file size. On a slow remote mount (S3, B2, R2, SFTP) integrity verification can take a long time — schedule it during off-peak hours and use --resume if the job is interrupted.