Skip to content

fix: scheduled CSV refresh runs without a logged-in user#1333

Open
Alexia-Soare wants to merge 1 commit into
developmentfrom
fix/schedule-csv
Open

fix: scheduled CSV refresh runs without a logged-in user#1333
Alexia-Soare wants to merge 1 commit into
developmentfrom
fix/schedule-csv

Conversation

@Alexia-Soare

@Alexia-Soare Alexia-Soare commented Jul 8, 2026

Copy link
Copy Markdown

Fixes the scheduled remote-CSV auto-sync silently stopping. Related issue: https://github.com/Codeinwp/visualizer-pro/issues/590

Problem

Background schedule/refresh calls uploadData() with no logged-in user and VISUALIZER_DO_NOT_DIE set. Since Feb 2026 that handler also requires edit_posts/edit_post, so with no user the check fails and the internal call returns silently — the chart never refreshes while Pro advances the next-run time anyway.

Fix

Gate the two capability checks on $can_die so they apply to real web requests only. Trusted internal calls (the sole context that defines VISUALIZER_DO_NOT_DIE, never from request input) proceed and import.

Safety

  • Web path unchanged: when $can_die is true the expressions are identical to before, so all existing checks (incl. the nonce) stay enforced.
  • VISUALIZER_DO_NOT_DIE is defined only in internal scheduled handlers, never from request data, so the relaxation can't be reached by an attacker.

Tests

tests/test-schedule.php — asserts a no-user internal import updates the chart; green with the fix, red without. Full suite passes (the only errors are a pre-existing tsdk_utmify() gap in Test_Revisions, unrelated).

Background schedule/refresh invokes the upload handler with no logged-in
user and VISUALIZER_DO_NOT_DIE set. Since Feb 2026 uploadData() also
requires edit_posts/edit_post, so the scheduled import silently returned
and charts stopped auto-updating.

Gate the two capability checks on $can_die so they apply to real web
requests only; trusted internal calls (the only context that defines
VISUALIZER_DO_NOT_DIE, never from request input) proceed. Web path and
the nonce check are unchanged.

Fixes Codeinwp/visualizer-pro#590

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Alexia-Soare Alexia-Soare added the pr-checklist-skip Allow this Pull Request to skip checklist. label Jul 8, 2026
@pirate-bot pirate-bot added the pr-checklist-complete The Pull Request checklist is complete. (automatic label) label Jul 8, 2026
@pirate-bot

Copy link
Copy Markdown
Contributor

Plugin build for 0ef6336 is ready 🛎️!

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

Labels

pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants