Avoid Exception in AdvertismentConverter.php and Return NULL Instead

Created on 24 March 2025, 16 days ago

Problem/Motivation

Why does the /admin/content/simpleads/NON_EXISTENT_AD_ID/stats route throw an InvalidArgumentException instead of behaving like the /admin/content/simpleads/NON_EXISTENT_AD_ID/edit route, which simply returns a "Page not found" page?

InvalidArgumentException: Unable to load SimpleAds advertisement entity. in Drupal\simpleads\Entity\ParamConverter\AdvertisementConverter->convert() (line 30 of modules/contrib/simpleads/src/Entity/ParamConverter/AdvertisementConverter.php).

Proposed resolution

Modify the convert() method to return NULL instead of throwing an exception when the entity cannot be loaded.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇭🇺Hungary fox mulder

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

Comments & Activities

Production build 0.71.5 2024