Skip to content

fix: quiet per-request db.php version-check log noise - #48

Open
mrtwebdesign wants to merge 1 commit into
developmentfrom
fix/verbose-log-noise-form-db.php
Open

fix: quiet per-request db.php version-check log noise#48
mrtwebdesign wants to merge 1 commit into
developmentfrom
fix/verbose-log-noise-form-db.php

Conversation

@mrtwebdesign

Copy link
Copy Markdown
Contributor

Summary

Quiets the per-request [hypercart_query_guard][warn] db.php drop-in tested on WP … log noise emitted by the wp-content/db.php drop-in. The warning was firing on every request whenever WordPress was on a patch release within the tested line (e.g. 7.0.2), flooding the logs.

Root cause

HCQG_DB::hcqg_version_check() ran in the constructor on every request and compared the full $wp_version string against a 7.0 ceiling with version_compare( …, '>' ). Any patch inside the tested line — 7.0.1, 7.0.2 — compares greater than '7.0', so a compatible patch release tripped the warning on every page load. The emit was also ungated by mode and not de-duplicated.

Fix (db.php)

  • Compare on MAJOR.MINOR$wp_version is reduced to 7.0 (patch and pre-release suffixes stripped) before the version_compare, so 7.0.x patches register as in-range.
  • Emit at most once per process via a new private static $hcqg_version_warned guard.
  • Skip entirely in off mode — the check early-returns unless instrumentation is active.
  • Reconciled the docblock — the stale 5.5 – 6.8 comment now matches the 7.0 ceiling and documents the major.minor comparison.

The warning still fires — once — for a genuinely untested major/minor (e.g. a real 7.1/8.0), preserving the safety net.

Testing

  • php -l db.php — clean
  • DbDropinTest — 12 tests, 21 assertions passing

Notes

  • The static guard de-dups within a request/process; the practical spam elimination comes from the major.minor comparison. Cross-request throttling for an untested major would need a transient, which isn't safe to touch at drop-in construction time.
  • The version-warning path has no dedicated test coverage. Happy to add one (assert 7.0.2 stays quiet while 7.1/5.4 warn once) in a follow-up.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants