Problem/Motivation
When an index includes a field like "body:processed", the rendering process uses a different theme when the item is saved and indexed individually or using the index UI to trigger a bulk index. Those processes use the admin theme but using Drush to index uses the default theme.
Steps to reproduce
- Create an index for a content type that uses the field's ":processed" value.
- Drop a breakpoint in web/core/lib/Drupal/Core/Render/Renderer.php, renderPlain() to see the active theme during the indexing process.
- Edit a node and note the active theme at the breakpoint.
- Run the full, bulk indexing process using the UI and note the active theme at the breakpoint.
- Run the full, bulk indexing process using drush and note the active theme at the breakpoint.
Each of these indexing process should be using the same theme for data integrity.
Proposed resolution
Remaining tasks
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 3320841-12--use_default_theme_for_processed_text.patch | 18.7 KB | drunken monkey |
Comments
Comment #2
weekbeforenextComment #3
weekbeforenextAttached is a patch. Not sure if it's the best solution, but it's a first attempt that seems to be working.
Comment #4
weekbeforenextNew patch that defines the themeSwitched() method in the FieldsHelperInterface.
Comment #7
weekbeforenextAdded test fixes.
Comment #8
weekbeforenextComment #10
weekbeforenextFixed more tests...
Comment #11
weekbeforenextComment #12
drunken monkeyThanks for reporting this issue and already providing a patch for fixing it!
However, if the code is exactly the same in both places, then we should probably make it reusable in general. Unfortunately, this doesn’t really fit on any of the existing services, so I propose adding a new one. Patch attached, please test/review!
Comment #13
weekbeforenextThanks for the new patch! I like how the theme switching is now abstracted into it's own service.
The patch applies successfully. I verified the test instructions for a project ticket that kicked off this issue and they still pass.
Reviewing the patch itself, the code looks good to me.
Thanks again!
Comment #14
weekbeforenextComment #16
drunken monkeyGreat to hear, thanks a lot for testing and reviewing!
Merged.
Thanks again!