Skip to content

Pattern Translations: Restore cron job output under Cavalcade - #785

Merged
obenland merged 1 commit into
trunkfrom
fix/cron-output
Oct 5, 2026
Merged

obenland merged 1 commit into
trunkfrom
fix/cron-output

Conversation

@obenland

@obenland obenland commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #784.

The pattern translation cron jobs have logged no output since the sync of ca865d8 on 2026-09-15. That cleanup replaced their echo/printf calls with WP_CLI::log() guarded by defined( 'WP_CLI' ) && WP_CLI. On WordPress.org, Cavalcade doesn't start jobs through WP-CLI: bin/cavalcade/dotorg-hooks.php runs them via wp-loader.php, which loads WordPress directly, so WP_CLI is never defined and every guarded call is skipped. The runner records whatever a job writes to stdout/stderr, so plain output gets captured.

The parent job's Cavalcade log shows the cutoff: Queued 46 cron jobs of 50 Patterns each. is present on every run through 2026-09-15 06:46 UTC and absent from 18:46 UTC onward.

Not tested under Cavalcade. phpcs passes.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • Cron progress updates—including import results, queued jobs, pattern and locale statuses, errors, and missing translations—are now available in WP-CLI output or as plain text when WP-CLI is unavailable.
    • Translation failures continue to be recorded in the server error log.

On WordPress.org, Cavalcade runs jobs through a custom loader rather than
WP-CLI, so `WP_CLI` is never defined and the guarded `WP_CLI::log()` calls
print nothing. Job output has been empty since those calls replaced the
previous `echo`/`printf` statements.

Route progress messages through a helper that uses WP_CLI::log() under
WP-CLI and echoes otherwise, and remove the per-pattern error_log() that
was added as a workaround.
Copilot AI balanced review requested due to automatic review settings October 5, 2026 18:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2fad4f2e-f4c0-4ace-869c-dbaa637d8dab
📥 Commits

Reviewing files that changed from the base of the PR and between 21252e9 and b32bebd.

📒 Files selected for processing (1)
  • public_html/wp-content/plugins/pattern-translations/includes/cron.php

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

Cron progress messages now use log_message(). The function sends messages to WP-CLI when available and otherwise echoes newline-terminated text. Translation failures continue to be written to the server error log.

Changes

Cron progress logging

Layer / File(s) Summary
Route cron messages through the shared logger
public_html/wp-content/plugins/pattern-translations/includes/cron.php
GlotPress import results, queued-job counts, pattern progress, and locale update, create, failure, and missing-translation messages now use log_message(). The function uses WP-CLI when available and otherwise echoes each message with a newline. Translation failures remain in the server error log.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to b32be

Progress messages now fall back to PHP output when WP-CLI is unavailable, but Cavalcade’s handling of that output is not confirmed here. No material merge-blocking risk is established; residual risk is minimal.

Architecture Summary

Architecture risk: 🔵 Low · up to b32be

The change affects 1 system.

Changed systems: public_html

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — public_html (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in public_html/wp-content/plugins/pattern-translations/includes/cron.php: The GlotPress import result now goes through log_message() instead of being logged only when WP-CLI is available.
  • observed — Modified behavior in public_html/wp-content/plugins/pattern-translations/includes/cron.php: The queued-job count now goes through log_message() instead of being emitted only under WP-CLI.
  • observed — Modified behavior in public_html/wp-content/plugins/pattern-translations/includes/cron.php: The total-pattern/locale status and per-pattern progress now use log_message() rather than WP-CLI-only output. The cron-specific error_log() identifying the pattern being processed was removed.
  • observed — Modified behavior in public_html/wp-content/plugins/pattern-translations/includes/cron.php: Per-locale update/create, failure, and no-translation messages now use log_message() instead of WP-CLI-conditional logging. Failures remain written to the server error log.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: restoring cron job output under Cavalcade.
Description check ✅ Passed The description explains the issue, the cause, and the planned fix, and it references follow-up PR #784. It omits the template’s Props, Screenshots, and How to test sections, but it includes the repor…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@obenland
obenland merged commit 059f7e1 into trunk Oct 5, 2026
5 checks passed
@obenland
obenland deleted the fix/cron-output branch October 5, 2026 18:22
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