fix(settings): wp_date() respects WP timezone; clarify counter is not atomic

- Replace date('Y-m-d') with wp_date('Y-m-d') in increment_drop_counter and
  default_drop_counters to respect WordPress timezone settings.
- Update corresponding test assertions to use wp_date() for consistency.
- Clarify in docblock that increment_drop_counter is not atomic under concurrent
  submissions; read-modify-write pattern via update_option is acceptable for
  low-volume dashboard counters.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vladimir Bryzgalov
2026-04-21 16:25:30 +05:00
parent ae70b42dcb
commit 0034531a3a
2 changed files with 8 additions and 5 deletions
+2 -2
View File
@@ -49,7 +49,7 @@ final class SettingsCounterTest extends Cf7stgTestCase
Settings::increment_drop_counter('real');
$c = Settings::get_drop_counters();
self::assertSame(date('Y-m-d'), $c['today_date']);
self::assertSame(wp_date('Y-m-d'), $c['today_date']);
self::assertSame(5, $c['real_yesterday']);
self::assertSame(1, $c['real_today']);
self::assertSame(6, $c['total']);
@@ -64,7 +64,7 @@ final class SettingsCounterTest extends Cf7stgTestCase
self::assertSame(0, $c['total']);
self::assertSame(0, $c['real_today']);
self::assertSame(0, $c['dry_today']);
self::assertSame(date('Y-m-d'), $c['reset_at']);
self::assertSame(wp_date('Y-m-d'), $c['reset_at']);
}
public function test_get_dry_run_drop_default_true_when_unset(): void