Commit 3ccb9ab2 authored by Milos Bovan's avatar Milos Bovan Committed by Damien McKenna
Browse files

Issue #3175269 by mbovan, DamienMcKenna: Pass optional bubbleable metadata...

Issue #3175269 by mbovan, DamienMcKenna: Pass optional bubbleable metadata parameter to generateRawElements to avoid issues with early rendering and JSON:API.
parent 9e90638e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ Metatag 8.x-1.x-dev, xxxx-xx-xx
  with assertEmpty()/assertNotEmpty()/assertArrayNotHasKey().
#2782797 by DamienMcKenna: Added missing $defaultTheme test variable.
#3159192 by heddn: Hide from translation system from unsupported entities.
#3175269 by mbovan, DamienMcKenna: Pass optional bubbleable metadata parameter
  to generateRawElements to avoid issues with early rendering and JSON:API.


Metatag 8.x-1.14, 2020-08-11
+5 −2
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\views\ViewEntityInterface;

@@ -501,11 +502,13 @@ class MetatagManager implements MetatagManagerInterface {
   *   The array of tags as plugin_id => value.
   * @param object $entity
   *   Optional entity object to use for token replacements.
   * @param \Drupal\Core\Render\BubbleableMetadata|null $cache
   *   (optional) Cacheability metadata.
   *
   * @return array
   *   Render array with tag elements.
   */
  public function generateRawElements(array $tags, $entity = NULL) {
  public function generateRawElements(array $tags, $entity = NULL, BubbleableMetadata $cache = NULL) {
    // Ignore the update.php path.
    $request = \Drupal::request();
    if ($request->getBaseUrl() == '/update.php') {
@@ -562,7 +565,7 @@ class MetatagManager implements MetatagManagerInterface {
        $tag->setValue($value);

        // Obtain the processed value.
        $processed_value = htmlspecialchars_decode($this->tokenService->replace($tag->value(), $token_replacements, ['langcode' => $langcode]));
        $processed_value = htmlspecialchars_decode($this->tokenService->replace($tag->value(), $token_replacements, ['langcode' => $langcode], $cache));

        // Now store the value with processed tokens back into the plugin.
        $tag->setValue($processed_value);