When rendering an uncached node with a media acquia dam file, media_theme_suggestions_media is making calls out to Acquia DAM.

The hook media_theme_suggestions_madia calls to the media_acquia_dam when the media module adds suggestions based on the source plugin ID. When the module calls $source = $media->getSource(); it instantiated the media_acquiadam media entity class.
The problem is the plugin constructor calls the assetMetadataHelper service to set the MetadataXmpFields but to set this metadata it calls the acquia dam to get the ActiveXmpFields

The suggestion based on the source plugin is: media__source_acquiadam_asset
An example list of suggestions is:

  • "media__full"
  • "media__acquia_dam_image"
  • "media__acquia_dam_image__full"
  • "media__source_acquiadam_asset"
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MauHG created an issue. See original summary.

MauHG’s picture

Patch to move the call to acquiadam API from media plugin to metadata helper service.

jhedstrom’s picture

Status: Active » Needs review
jhedstrom’s picture

This is looking good. The solution of only setting the xmp metadata when it's requested will speed things up quite a bit I think.

Just one tiny bit of feedback on the code so far:

+++ b/src/Plugin/media/Source/AcquiadamAsset.php
@@ -80,14 +71,11 @@ class AcquiadamAsset extends MediaSourceBase {
+    // $this->acquiadam = $acquiadam;

This commented out item can probably just be removed instead.

MauHG’s picture

jhedstrom thanks for the feedback. Here is an updated patch.

jhedstrom’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/src/Client.php
@@ -49,7 +49,8 @@ class Client extends OriginalClient {
+      $this->activeXmpFields = [];
+      return $this->activeXmpFields;

This is a good catch! Without this failed authentication repeats for each image or asset. I think this should be good to go.

  • jmoreira committed 07bd9d6 on 8.x-1.x
    Issue #3131412: Removing unused use statement.
    
  • jmoreira committed a8aeacc on 8.x-1.x authored by MauHG
    Issue #3131412 by MauHG: media_theme_suggestions_media making calls to...
  • jmoreira committed e57a16e on 8.x-1.x
    Issue #3131412: Removing temporary method to make tests pass on Drupal 8...
  • jmoreira committed eb76c26 on 8.x-1.x
    Issue #3131412: Fixing kernel tests after acquiadam service was removed...
jmoreira’s picture

Version: 8.x-1.x-dev » 8.x-1.44
Status: Reviewed & tested by the community » Fixed
jmoreira’s picture

Status: Fixed » Closed (fixed)