KaufmannDigital.GDPR.CookieConsent icon indicating copy to clipboard operation
KaufmannDigital.GDPR.CookieConsent copied to clipboard

Fix type error when no consents have been set yet

Open kdambekalns opened this issue 2 years ago • 1 comments

Make sure $consents is an array instead of null when not set in $cookie at all.

Fixes #47

kdambekalns avatar Aug 17 '22 16:08 kdambekalns

Thanks for your PR @kdambekalns!

Unfortunately, I could not reproduce the problem. The code is located in a try-catch block. This should actually ensure that these exceptions get catched and an empty JavaScript is generated, as long as not all necessary parameters are set via the cookie.

In my tests, the whole thing worked, so that it never came to the error (PHP 8.1). Only if I remove the try-catch block, I get an error.
The fix does not lead to any other error, but I still get other exceptions with the fix, which lead to the same result with try-catch.

Maybe I'm missing something and you can help me out.... You can also reach my via Slack, if thats easier :)

Nikdro avatar Aug 18 '22 13:08 Nikdro

Hi @kdambekalns, I wasn't able again to reproduce your described problem. But since this should not break something and it worked for me in my tests, I'll get this into v5 now.

Nikdro avatar Nov 01 '22 12:11 Nikdro

Sorry for not getting back to this, I had hoped to find time to verify it again. But the issue was real… 🤷‍♂️

Thanks for merging! ❤️‍🔥

kdambekalns avatar Nov 03 '22 07:11 kdambekalns