It might happen that a user no longer exists in the system, so we need a bit of defensive programming around the list builder to look for that.

The error returned if a notification is generated and the user does not exist is

Error: Call to a member function link() on null in Drupal\opigno_notification\Entity\Controller\OpignoNotificationListBuilder->buildRow()

Comments

pcambra created an issue. See original summary.

pcambra’s picture

Status: Active » Needs review
StatusFileSize
new1.62 KB
pcambra’s picture

Issue summary: View changes
pcambra’s picture

StatusFileSize
new2 KB

This one better.

webadpro’s picture

I'm thinking, shouldn't these messages get cleaned up if a user gets deleted? I just think it leaves unnecessary data in the database which will never be used again. So rather than looking up if a user exists, why not add an event hook to delete the messages?

pcambra’s picture

@webadpro maybe someone wants to keep them because of archiving reasons? I think this patch should still be valid as part of a defensive strategy of not throwing errors just in case.

I'll add a different issue for dropping notifications on user deletion and let's see what the maintainers think.

pcambra’s picture

pcambra’s picture

StatusFileSize
new2.07 KB
webadpro’s picture

@pcambra, yeah I don't see any issues getting this patch in although I'm leaning to this other issue as a better fix. Lets see what Axel or his team will decide.

axelm’s picture

@pcambra
Thanks, it will be implemented in next release

axelm’s picture

Status: Needs review » Patch (to be ported)
axelm’s picture

Status: Patch (to be ported) » Fixed
axelm’s picture

Status: Fixed » Closed (fixed)