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

fatal type error in Hasher #52

Closed
Oreolek opened this issue Mar 6, 2024 · 7 comments
Closed

fatal type error in Hasher #52

Oreolek opened this issue Mar 6, 2024 · 7 comments

Comments

@Oreolek
Copy link

Oreolek commented Mar 6, 2024

PHP Fatal error: Uncaught TypeError: Piwik\Plugins\ProtectTrackID\Hasher::decode(): Return value must be of type int, null returned in /plugins/ProtectTrackID/Hasher.php:44

@joubertredrat
Copy link
Owner

Hi @Oreolek, could you provide more information about this error for our debug? For example: Matomo version, PHP version.

@Oreolek
Copy link
Author

Oreolek commented Apr 2, 2024

current stable, php8.2

@joubertredrat
Copy link
Owner

Hi @Oreolek. I made a test here using last Matomo 5 and plugin version, PHP 8.3.4 and I didn't see any errors here, tracking was working normally.

Are you having this issue in plugin configuration or during tracking? Is it possible to check if your server have PHP bcmath, gmp and mbstring extensions installed?

@joubertredrat
Copy link
Owner

I added unit tests for PHP since 7.3 to 8.2, as possible to see here. #53

@Oreolek
Copy link
Author

Oreolek commented Apr 11, 2024

I didn't have gmp installed, yes.
But why is this relevant? Isn't it enough to edit one line in Hasher.php and force an int type instead of NULL?

return (int) $this->hashids->decode($value)[0];

https://github.com/joubertredrat/Matomo-ProtectTrackID/blob/master/Hasher.php#L41

@joubertredrat
Copy link
Owner

joubertredrat commented Apr 11, 2024

@Oreolek you need to have bcmath and gmp extensions installed for the lib used by plugin to be able to do arbitrary and multiple precision mathematics during encode or decode process.

I guess this is the reason you facing this issue.

About your suggestion for edit the #L41, I will add validations and throw exceptions for prevent this, but the method already expect int as return type, then we need to understand the reason that in your case is trying to returning null instead of this.

@joubertredrat
Copy link
Owner

No response, then I'm assuming that was solved

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

No branches or pull requests

2 participants