KaufmannDigital / KaufmannDigital.GDPR.CookieConsent

A ready-to-run package, that integrates an advanced cookie consent banner into your Neos CMS site.
https://www.kaufmann.digital/neos-cms/plugins/dsgvo-gdpr-cookie-consent
GNU General Public License v3.0
26 stars 11 forks source link

Fix: errors thrown when cookie is not set #45

Closed hphoeksma closed 1 year ago

hphoeksma commented 2 years ago

Fixes a Notice: Undefined index: KD_GDPR_CC warning when the cookie is not yet set by the user.

Nikdro commented 1 year ago

Hi @hphoeksma!

First of all sorry for my late response and thanks for your contribution! There was a bit more to do on this package and we wasn't able to do it until now.

When/How did you get the error, you described and made you do this fix? I just tried it on our projects, and everything worked fine, even if the user did not select something and the Cookie wasn't set.
There is a try-catch block around all the logic, which prevents Neos from throwing errors on such a case. Instead just an empty response is returned. (See https://github.com/KaufmannDigital/KaufmannDigital.GDPR.CookieConsent/blob/master/Classes/Controller/JavaScriptController.php#L141)

Could you come up with an example, how to reproduce your problem? I would really like to find the problem here :) Thank you very much!

Niklas

hphoeksma commented 1 year ago

@Nikdro I need to dive into when I ran into this... At the moment I am running low on time to do so. I will make a remark on my todo list to get to this asap!

Nikdro commented 1 year ago

Thanks! Looking forward to hear from you!

franzkugelmann commented 1 year ago

Isn't that the same issue as solved with https://github.com/KaufmannDigital/KaufmannDigital.GDPR.CookieConsent/pull/48?

hphoeksma commented 1 year ago

@Nikdro I just updated the Neos distribution I am using this in with the latest version, and the error returns again: Warning: Undefined array key "KD_GDPR_CC"

It kinda makes sense since on line 86 you call an array with the cookie name index without checking if the index is set:

$cookie = json_decode($this->request->getHttpRequest()->getCookieParams()[$this->cookieName], true);

I updated the code to match the current master state.

hphoeksma commented 1 year ago

@franzkugelmann

Isn't that the same issue as solved with #48?

No, as the error is triggered in the line above that one.

Nikdro commented 1 year ago

Thank you very much @hphoeksma! Just published new Versions with your fix!