Commit 41693dd6 authored by Markus Kalkbrenner's avatar Markus Kalkbrenner Committed by Markus Kalkbrenner
Browse files

Issue #3281382 by mkalkbrenner, BAHbKA: fine tune processor cache meta data

parent 763981d3
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\facets\Plugin\facets\hierarchy;

use Drupal\Core\Cache\UnchangingCacheableDependencyTrait;
use Drupal\facets\Hierarchy\HierarchyPluginBase;

/**
@@ -15,6 +16,8 @@ use Drupal\facets\Hierarchy\HierarchyPluginBase;
 */
class DateItems extends HierarchyPluginBase {

  use UnchangingCacheableDependencyTrait;

  /**
   * Static cache for the parents.
   *
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\facets\Plugin\facets\processor;

use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\UnchangingCacheableDependencyTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
@@ -133,7 +134,7 @@ class TermWeightWidgetOrderProcessor extends SortProcessorPluginBase implements
   * {@inheritdoc}
   */
  public function getCacheTags() {
    return ['taxonomy_term:list'];
    return Cache::mergeTags(parent::getCacheTags(), ['taxonomy_term_list']);
  }

}
+17 −3
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\facets\Plugin\facets\processor;

use Drupal\Core\Cache\UnchangingCacheableDependencyTrait;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Config\ConfigManagerInterface;
@@ -32,8 +31,6 @@ use Drupal\Core\TypedData\TranslatableInterface;
 */
class TranslateEntityAggregatedFieldProcessor extends ProcessorPluginBase implements BuildProcessorInterface, ContainerFactoryPluginInterface {

  use UnchangingCacheableDependencyTrait;

  /**
   * The language manager.
   *
@@ -235,4 +232,21 @@ class TranslateEntityAggregatedFieldProcessor extends ProcessorPluginBase implem
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return Cache::mergeContexts(parent::getCacheContexts(), ['languages:language_interface']);
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    // This will work unless the Search API Query uses "wrong" caching. Ideally
    // we would set a cache tag to invalidate the cache whenever a translatable
    // entity is added or changed. But there's no tag in drupal yet.
    return Cache::PERMANENT;
  }

}
+18 −3
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

namespace Drupal\facets\Plugin\facets\processor;

use Drupal\Core\Cache\UnchangingCacheableDependencyTrait;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
@@ -29,8 +29,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 */
class TranslateEntityProcessor extends ProcessorPluginBase implements BuildProcessorInterface, ContainerFactoryPluginInterface {

  use UnchangingCacheableDependencyTrait;

  /**
   * The language manager.
   *
@@ -161,4 +159,21 @@ class TranslateEntityProcessor extends ProcessorPluginBase implements BuildProce
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return Cache::mergeContexts(parent::getCacheContexts(), ['languages:language_interface']);
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    // This will work unless the Search API Query uses "wrong" caching. Ideally
    // we would set a cache tag to invalidate the cache whenever a translatable
    // entity is added or changed. But there's no tag in drupal yet.
    return Cache::PERMANENT;
  }

}
+15 −3
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

namespace Drupal\facets\Plugin\facets\processor;

use Drupal\Core\Cache\UnchangingCacheableDependencyTrait;
use Drupal\Core\Cache\Cache;
use Drupal\Core\TypedData\ComplexDataDefinitionInterface;
use Drupal\Core\TypedData\DataReferenceDefinitionInterface;
use Drupal\facets\FacetInterface;
@@ -24,8 +24,6 @@ use Drupal\user\Entity\User;
 */
class UidToUserNameCallbackProcessor extends ProcessorPluginBase implements BuildProcessorInterface {

  use UnchangingCacheableDependencyTrait;

  /**
   * {@inheritdoc}
   */
@@ -72,4 +70,18 @@ class UidToUserNameCallbackProcessor extends ProcessorPluginBase implements Buil
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return Cache::PERMANENT;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    return Cache::mergeTags(parent::getCacheTags(), ['user_list']);
  }

}