Commit 59228ae7 authored by Kimberley Massey's avatar Kimberley Massey Committed by Thomas Seiber
Browse files

Issue #3266715 by kimberleycgm, drunken monkey: Fixed "Rendered item"...

Issue #3266715 by kimberleycgm, drunken monkey: Fixed "Rendered item" processor not adding the "Authenticated" role when another is selected.
parent 66aea025
Loading
Loading
Loading
Loading
+2 −0
Changes for CHANGELOG.txt: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
Search API 1.x, dev (xxxx-xx-xx):
---------------------------------
- #3266715 by kimberleycgm, drunken monkey: Fixed "Rendered item" processor not
  adding the "Authenticated" role when another is selected.
- #3270695 by mkalkbrenner, drunken monkey: Improved status messages during
  indexing.
- #3268953 by drunken monkey: Changed indents in composer.json to 4 spaces.
+10 −1
Changes for src/Plugin/search_api/processor/RenderedItem.php: 10 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ use Drupal\search_api\Item\ItemInterface;
use Drupal\search_api\LoggerTrait;
use Drupal\search_api\Plugin\search_api\processor\Property\RenderedItemProperty;
use Drupal\search_api\Processor\ProcessorPluginBase;
use Drupal\user\RoleInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
@@ -256,10 +257,18 @@ class RenderedItem extends ProcessorPluginBase {
    foreach ($fields as $field) {
      $configuration = $field->getConfiguration();

      // If a (non-anonymous) role is selected, then also add the authenticated
      // user role.
      $roles = $configuration['roles'];
      $authenticated = RoleInterface::AUTHENTICATED_ID;
      if (array_diff($roles, [$authenticated, RoleInterface::ANONYMOUS_ID])) {
        $roles[$authenticated] = $authenticated;
      }

      // Change the current user to our dummy implementation to ensure we are
      // using the configured roles.
      $this->getAccountSwitcher()
        ->switchTo(new UserSession(['roles' => $configuration['roles']]));
        ->switchTo(new UserSession(['roles' => array_values($roles)]));

      $datasource_id = $item->getDatasourceId();
      $datasource = $item->getDatasource();