bynder_sns: Call to a member function toLink() on array.

Created on 12 September 2024, 3 months ago
Updated 20 September 2024, 3 months ago

Problem/Motivation

Getting an error while using "bynder_sns" module.

Error: Call to a member function toLink() on array in Drupal\bynder_sns\EventSubscriber\NotificationSubscriber->onNotification() (line 121 of /code/docroot/modules/contrib/bynder/modules/bynder_sns/src/EventSubscriber/NotificationSubscriber.php).

The error appears to be coming from this code...

      $mids = $query
        ->condition($source_field_condition)
        ->execute();

      if ($mids) {
        $media = $storage->loadMultiple($mids);
        $bynder_media_entities = [
          $message['media_id'] => $media,
        ];
        $updated = $this->bynder->updateMediaEntities($bynder_media_entities);
        if ($updated) {
          $this->loggerFactory->get('bynder_sns')->notice('Updated bynder asset @label (@media_id)', [
            'link' => $media->toLink($this->t('View'))->toString(),
            '@media_id' => $message['media_id'],
            '@label' => $media->label(),
          ]);
        }

Where $media is coming back as an array. Maybe we need a $media = reset($media);? Or do we intend to handle multiple entities, which I think I've seen on my site, but not sure how that came about...

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇺🇸United States dpagini

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024