codefog / contao-events_subscriptions

Contao extension that allows members of your website to subscribe to the events
MIT License
10 stars 5 forks source link

The subscription type "" does not exist #95

Open Kahmoon opened 1 year ago

Kahmoon commented 1 year ago

Hi Kamil,

i am managin subscribers via backend a lot. Sometimes it happens that there is created an "empty" subscription, which causes the complete website to crash if this event is listed. Var/logs contains the following error.

[2022-12-21T18:23:42.677219+01:00] request.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The subscription type "" does not exist" at /homepages/46/xxx/htdocs/xxx-v3/vendor/codefog/contao-events_subscriptions/src/Codefog/EventsSubscriptions/SubscriptionFactory.php line 52 {"exception":"[object] (InvalidArgumentException(code: 0): The subscription type \"\" does not exist at /homepages/46/xxx/htdocs/xxx-v3/vendor/codefog/contao-events_subscriptions/src/Codefog/EventsSubscriptions/SubscriptionFactory.php:52)"} []

At some state of the registration process there is created an entry without any "type". I cannot reproduce it. Probably it comes from creating a new subscription and abort before completing the process. This could explain why its neither guest or member at the current state. But its written to database to early isn´t it?

I have to remove this entry manually directly in the database. There is no other way.

How can we avoid this? Any idea?

Kahmoon commented 1 year ago

OK, now i can reproduce this error

Adding subscriber via backend and straight use back function of browser. Do not chose guest or member. Just go back. You now have an empty entry with type "". In this case the frontend will crash if this event is listen on this page.

SCR-20230131-hix

Trying to delete this empty subscription throws

SCR-20230131-hfb

Editing blank entry is possible.

There should be no frontend crash when type = "".