Skip to content

GH#1241: fix: add error handling and site-aware URLs to thank-you.js#1246

Merged
superdav42 merged 1 commit into
mainfrom
feature/auto-20260521-025721-gh1241
May 21, 2026
Merged

GH#1241: fix: add error handling and site-aware URLs to thank-you.js#1246
superdav42 merged 1 commit into
mainfrom
feature/auto-20260521-025721-gh1241

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

@superdav42 superdav42 commented May 21, 2026

Summary

Fixed two quality-debt issues in assets/js/thank-you.js:

  1. Error handling for resend verification email: Wrapped the fetch and response parsing in a try-catch block to handle network failures and JSON parsing errors. Added a fallback error message using the localized 'request_failed' i18n string.

  2. Site-aware wp-cron URLs: Replaced three hard-coded '/wp-cron.php?doing_wp_cron' URLs with a localized 'wp_cron_url' variable injected via wp_localize_script(). This ensures the URLs work correctly on WordPress subdirectory installs.

Changes:

  • inc/ui/class-thank-you-element.php: Added 'wp_cron_url' and 'request_failed' i18n string to localized script data
  • assets/js/thank-you.js: Added try-catch error handling, replaced hard-coded URLs, added eslint global comment

Files Changed

assets/js/thank-you.js,inc/ui/class-thank-you-element.php

Runtime Testing

  • Risk level: Low (agent prompts / infrastructure scripts)
  • Verification: Verified with ESLint and PHPCS linting; all style violations fixed

Resolves #1241


aidevops.sh v3.17.18 plugin for OpenCode v1.15.6 with claude-haiku-4-5 spent 2m and 3,246 tokens on this as a headless worker.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced error handling when resending verification emails, providing clearer user feedback with internationalization support for error messages
    • Improved reliability of WordPress background task execution during site creation through optimized triggering and periodic monitoring
    • Strengthened user experience with comprehensive error tracking and improved feedback communication on the thank you page

Review Change Stack

@superdav42 superdav42 added the origin:worker Auto-created by pulse labelless backfill (t2112) label May 21, 2026
@superdav42
Copy link
Copy Markdown
Collaborator Author

Completion Summary

  • What: Fixed two quality-debt issues in assets/js/thank-you.js:
  1. Error handling for resend verification email: Wrapped the fetch and response parsing in a try-catch block to handle network failures and JSON parsing errors. Added a fallback error message using the localized 'request_failed' i18n string.

  2. Site-aware wp-cron URLs: Replaced three hard-coded '/wp-cron.php?doing_wp_cron' URLs with a localized 'wp_cron_url' variable injected via wp_localize_script(). This ensures the URLs work correctly on WordPress subdirectory installs.

Changes:

  • inc/ui/class-thank-you-element.php: Added 'wp_cron_url' and 'request_failed' i18n string to localized script data
  • assets/js/thank-you.js: Added try-catch error handling, replaced hard-coded URLs, added eslint global comment
  • Issue: quality-debt: assets/js/thank-you.js — PR #1222 review feedback (medium) #1241
  • Files changed: assets/js/thank-you.js,inc/ui/class-thank-you-element.php
  • Testing: Verified with ESLint and PHPCS linting; all style violations fixed
  • Key decisions: none

aidevops.sh v3.17.18 plugin for OpenCode v1.15.6 with claude-haiku-4-5 spent 2m and 3,246 tokens on this as a headless worker.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a0c0c61f-7930-423a-81ab-0503dca85b72

📥 Commits

Reviewing files that changed from the base of the PR and between f18968f and 8877a55.

📒 Files selected for processing (2)
  • assets/js/thank-you.js
  • inc/ui/class-thank-you-element.php

📝 Walkthrough

Walkthrough

The PR addresses two medium-severity review findings from #1241. The backend now localizes a dynamic WP Cron URL and error message string. The frontend wraps the resend-verification request in try/catch to handle failures visibly, and replaces hardcoded /wp-cron.php paths with the localized URL at mount and during periodic polling.

Changes

Thank-you page error handling and WP Cron URL localization

Layer / File(s) Summary
Backend data localization
inc/ui/class-thank-you-element.php
register_scripts() localizes wp_cron_url endpoint and request_failed i18n string to the wu-thank-you script data.
Frontend error handling and dynamic WP Cron
assets/js/thank-you.js
Global declaration and ESLint directives added; resend-verification handler wrapped in try/catch with safe message extraction and i18n fallback; hardcoded WP Cron URLs replaced with localized wu_thank_you.wp_cron_url at component mount and periodic polling checkpoints.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • Ultimate-Multisite/ultimate-multisite#972: Modifies thank-you polling and running_count transition handling to prevent infinite reloads; the main PR updates the same polling branches to trigger WP Cron via localized URL.
  • Ultimate-Multisite/ultimate-multisite#1040: Modifies check_site_created() and polling state transitions around running_count thresholds; directly adjacent to the same conditional branches updated in this PR for dynamic WP Cron triggering.

Poem

🐰 Hop and fetch with safety care,
No more hardcoded URLs laid bare,
Try, catch, and errors shown with grace,
Subdirectories find their place!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main changes: adding error handling and site-aware URLs to thank-you.js, which matches the PR objectives and linked issue requirements.
Linked Issues check ✅ Passed The PR addresses both requirements from issue #1241: wrapping resend-email flow in try/catch with localized error handling, and replacing three hard-coded wp-cron URLs with a localized wp_cron_url variable.
Out of Scope Changes check ✅ Passed All changes are directly related to issue #1241: error handling in resend-email flow, site-aware wp-cron URLs, ESLint directives, and necessary PHP localization updates. No unrelated changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auto-20260521-025721-gh1241

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 and usage tips.

@github-actions
Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@github-actions
Copy link
Copy Markdown

Performance Test Results

Performance test results for bff7879 are in 🛎️!

Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown.

URL: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 40 (-1 / -3% ) 37.78 MB 644.50 ms 131.00 ms 823.00 ms 1564.00 ms 1500.10 ms 66.55 ms
1 56 49.13 MB 726.50 ms 107.00 ms 834.00 ms (-18.00 ms / -2% ) 1610.00 ms 1547.70 ms 61.90 ms

@superdav42 superdav42 merged commit a80f017 into main May 21, 2026
11 checks passed
@superdav42
Copy link
Copy Markdown
Collaborator Author

Completion Summary

  • What: Fixed two quality-debt issues in assets/js/thank-you.js:
  1. Error handling for resend verification email: Wrapped the fetch and response parsing in a try-catch block to handle network failures and JSON parsing errors. Added a fallback error message using the localized 'request_failed' i18n string.

  2. Site-aware wp-cron URLs: Replaced three hard-coded '/wp-cron.php?doing_wp_cron' URLs with a localized 'wp_cron_url' variable injected via wp_localize_script(). This ensures the URLs work correctly on WordPress subdirectory installs.

Changes:

  • inc/ui/class-thank-you-element.php: Added 'wp_cron_url' and 'request_failed' i18n string to localized script data
  • assets/js/thank-you.js: Added try-catch error handling, replaced hard-coded URLs, added eslint global comment
  • Issue: quality-debt: assets/js/thank-you.js — PR #1222 review feedback (medium) #1241
  • Files changed: assets/js/thank-you.js,inc/ui/class-thank-you-element.php
  • Testing: Verified with ESLint and PHPCS linting; all style violations fixed
  • Key decisions: none

aidevops.sh v3.17.18 plugin for OpenCode v1.15.6 with claude-haiku-4-5 spent 2m and 3,246 tokens on this as a headless worker.


Merged via PR #1246 to main.
Merged by deterministic merge pass (pulse-wrapper.sh).

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

Labels

origin:worker Auto-created by pulse labelless backfill (t2112)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quality-debt: assets/js/thank-you.js — PR #1222 review feedback (medium)

1 participant