Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Return value of Mindshape\MindshapeCookieConsent\Utility\CookieUtility::getCookieValue() must be of the type array or null, bool returned #43

Closed
klodeckl opened this issue Jul 10, 2023 · 6 comments

Comments

@klodeckl
Copy link

Hi,

my TYPO3 log gets floodes with messages like:

Core: Exception handler (WEB): Uncaught TYPO3 Exception: Return value of Mindshape\MindshapeCookieConsent\Utility\CookieUtility::getCookieValue() must be of the type array or null, bool returned | TypeError thrown in file /xyz/typo3conf/ext/mindshape_cookie_consent/Classes/Utility/CookieUtility.php in line 34. Requested URL: https://www.tld.com/path/

Currently I don’t know how to reproduce the issue myself.

TYPO3 10, mindshape_cookie_consent 2.2.5

@featdd
Copy link
Member

featdd commented Jul 10, 2023

Hi @klodeckl,

the only explenation I currently have in mind that some users have a mess in their cookie value and the json_decode just returns a boolean.

Anyway, I will try to adjust this to prevent this exception.

Greetings
Daniel

@klodeckl
Copy link
Author

Thank you! :)
But how could get mess in the cookie value?

@klodeckl
Copy link
Author

klodeckl commented Jul 12, 2023

I changed the function now to the following:

if (false === self::hasCookie($name) || is_bool(json_decode($_COOKIE[$name], true)) === true) {
return null;
}

return json_decode($_COOKIE[$name], true);

I will check if the error won’t occur anymore now. Maybe instead of is_bool === true it would be better to check for is_array || is_null === false.

@featdd
Copy link
Member

featdd commented Oct 29, 2023

Hi @klodeckl,

I solved this here: 22bfbf2

This shouldn't happen except a user/script/adblocker tries to manipulate the consent cookie somehow, but this should make it safe now. (Broken cookies will also be ignored by the JavaScript prompting the modal and save it properly)

Greetings
Daniel

@featdd featdd closed this as completed Oct 29, 2023
@featdd
Copy link
Member

featdd commented Nov 10, 2023

Hi @klodeckl,

an update with this fix is now released in TER.

Greetings
Daniel

@klodeckl
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants