Opened 42 hours ago
Last modified 23 hours ago
#66818 new enhancement
Test the default editor when a saved editor preference is invalid
| Reported by: | lancewillett | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.3 |
| Component: | Editor | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
[65747] covers the default editor and an explicitly saved preference. If a user has an unrecognized editor setting, wp_default_editor() falls back to whether that user can use the rich editor. Cover both outcomes so a change that always selects TinyMCE or always selects HTML will fail.
Patch and test results: https://github.com/WordPress/wordpress-develop/pull/16222
Change History (3)
This ticket was mentioned in PR #16222 on WordPress/wordpress-develop by @mukesh27.
42 hours ago
#1
- Keywords has-patch has-unit-tests added
#3
@
23 hours ago
Tested PR #16222 locally against the latest trunk.
Single-site testing:
- Trunk (without patch): 3 tests passed, 3 assertions.
- PR patch: 5 tests passed, 5 assertions.
Multisite testing:
- PR patch: 5 tests passed, 5 assertions.
Verified the expected fallback behavior for invalid saved editor preferences with both rich editing enabled and disabled.
All tests passed with no failures or errors.
Result: Tested successfully.
Description
Follow-up to 65747, which added tests for
wp_default_editor().wp_default_editor()usesuser_can_richedit()only when the user'seditorsetting holds a value other thantinymce,html, ortest. Otherwiseget_user_setting( 'editor', 'tinymce' )decides the result, becausewp_get_current_user()always returns aWP_Userobject. The tests from [65747] never reach this fallback branch.This adds two invalid setting rows to the existing
test_wp_default_editor_respects_user_setting()test, which now uses a data provider:editorsettinguser_can_richedit()htmltruehtmlinvalidtruetinymceinvalidfalsehtmlThe first row is the existing case. It now also sets
user_can_richedit()totrue, which shows that a valid setting wins even when rich editing is available. All three rows share the existing cookie and$_updated_user_settingscleanup.Testing
npm run test:php -- --filter Tests_General_WpDefaultEditor: 5 tests pass on single site and multisite.tinymce, the "invalid setting, rich editing unavailable" row failed.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Finding the untested branch, writing the test, and drafting this description. I reviewed the result.
---
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
🤖 Generated with Claude Code