TypeError: Drupal\swiper_formatter\Plugin\views\style\SwiperFormatterStyle::getEntity()

Created on 16 January 2025, 6 days ago

Problem/Motivation

After upgrading to the 2.x branch, some of my swipers were white-screening the page with this error:

TypeError: Drupal\swiper_formatter\Plugin\views\style\SwiperFormatterStyle::getEntity(): Return value must be of type Drupal\Core\Entity\FieldableEntityInterface, null returned in Drupal\swiper_formatter\Plugin\views\style\SwiperFormatterStyle->getEntity() (line 294 of modules/contrib/swiper_formatter/src/Plugin/views/style/SwiperFormatterStyle.php).

Inspecting the situation with xdebug reveals that SwiperFormatterStyle::getEntity() is not looking in the correct spot for the ECK entity that is present there, and thus returning NULL. SwiperFormatterStyle::getEntity() declares that it will always return a FieldableEntityInterface, so when it returns NULL an error is thrown.

If ECK entities are affected, I'd imagine other entity types might also be.

Steps to reproduce

Attempt to view a swiper formatted view of ECK entities on the 2.x branch, see the error.

Proposed resolution

Update SwiperFormatterStyle::getEntity() to look more thoroughly through the row for the entity.

Remaining tasks

MR + review.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States chrisolof

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024