Problem/Motivation

When testing Quant Search, I was confused why my image and summary weren't showing up. It turns out it was because the token module was not installed so the field tokens weren't working.

Steps to reproduce

  1. Follow https://www.quantcdn.io/blog/tutorials/add-quant-search-drupal-9-static-...
  2. View the search page
  3. Result: The image and summary show up
  4. Uninstall the token module
  5. Reindex the search index
  6. View the search page
  7. Result: The image and summary are missing
  8. Expected Result: Some sort of warning or logging or something that an invalid token is being used

Proposed resolution

  • Consider adding help text and/or a warning on /admin/config/development/quant/search/entities
  • Ideally, check that any tokens provided are available
  • Ideally, update documentation to note the token module is often needed when updating entity tokens
  • We could also consider adding the token module as a dependency for Quant Search even though technically it doesn't need to be enabled

Remaining tasks

  1. Figure out which tasks above will be done
  2. Update code
  3. Update documentation
  4. Review and test
  5. Commit :)

User interface changes

TBD

API changes

Data model changes

Comments

Kristen Pol created an issue. See original summary.

kristen pol’s picture

Issue summary: View changes

Fix typo and slight rewording.

kristen pol’s picture

Assigned: Unassigned » kristen pol

Since we are defaulting the node image to [node:field_image:thumbnail:url] then we actually are dependent on the token module so we need to at least update the dependencies as a first step.

Once that's required, then we should be able to get the tokens with something like:

$tokens = \Drupal::service('token.tree_builder')->buildRenderable(['node']);

And do a regex of the form values to pull out any tokens and check them against this list. Then, add errors for any tokens that aren't found.

Here is some similar regex: https://api.drupal.org/api/drupal/includes%21token.inc/function/token_sc...

kristen pol’s picture

kristen pol’s picture

Status: Active » Needs review

This is ready for review.

kristen pol’s picture

Status: Needs review » Reviewed & tested by the community

This was merged 4 Dec 2022 in GitHub. But the branch needs to be synced to Drupal.

kristen pol’s picture

Assigned: kristen pol » Unassigned
Status: Reviewed & tested by the community » Fixed

Included in 1.4.0 release.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.