Skip to content
New issue

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

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

Already on GitHub? # to your account

Fatal error: Argument #1 ($string) must be of type string in ClientHints.php:285 #22846

Closed
tsteur opened this issue Dec 12, 2024 · 1 comment · Fixed by matomo-org/device-detector#7949
Assignees
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Dec 12, 2024

PHP Fatal error: Uncaught TypeError: trim(): Argument matomo-org/device-detector#1 ($string) must be of type string, null given in matomo/device-detector/ClientHints.php:285

And second PHP fatal error: PHP Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, null given in /var/www/html/vendor/matomo/device-detector/ClientHints.php:297 Stack trace: #0

This happens a few times per hour.

PHP: 8.2

Backtrace:

PHP Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, null given in /var/www/html/vendor/matomo/device-detector/ClientHints.php:285 Stack trace: #0 /var/www/html/vendor/matomo/device-detector/ClientHints.php(285): trim() #1 /var/www/html/core/DeviceDetector/DeviceDetectorFactory.php(46): DeviceDetector\ClientHints::factory() #2 /var/www/html/core/DeviceDetector/DeviceDetectorFactory.php(29): Piwik\DeviceDetector\DeviceDetectorFactory::getNormalizedUserAgent() #3 /var/www/html/core/Tracker/VisitExcluded.php(199): Piwik\DeviceDetector\DeviceDetectorFactory->makeInstance() #4 /var/www/html/core/Tracker/VisitExcluded.php(73): Piwik\Tracker\VisitExcluded->isNonHumanBot() #5 /var/www/html/plugins/CoreHome/Tracker/VisitRequestProcessor.php(104): Piwik\Tracker\VisitExcluded->isExcluded() #6 /var/www/html/core/Tracker/Visit.php(164): Piwik\Plugins\CoreHome\Tracker\VisitRequestProcessor->processRequestParams() #7 /var/www/html/core/Tracker.php(171): Piwik\Tracker\Visit->handle() #8 /var/www/html/core/Tracker/Handler.php(55): Piwik\Tracker->trackRequest() #9 /var/www/html/core/Tracker.php(151): Piwik\Tracker\Handler->process() #10 /var/www/html/core/Tracker.php(126): Piwik\Tracker->track() #11 /var/www/html/piwik.php(73): Piwik\Tracker->main() #12 /var/www/html/matomo.php(14): include('...') #13 {main} thrown in /var/www/html/vendor/matomo/device-detector/ClientHints.php on line 285

Second problem

PHP Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, null given in /var/www/html/vendor/matomo/device-detector/ClientHints.php:297 Stack trace: #0 /var/www/html/vendor/matomo/device-detector/ClientHints.php(297): trim() #1 /var/www/html/core/DeviceDetector/DeviceDetectorFactory.php(46): DeviceDetector\ClientHints::factory() #2 /var/www/html/core/DeviceDetector/DeviceDetectorFactory.php(29): Piwik\DeviceDetector\DeviceDetectorFactory::getNormalizedUserAgent() #3 /var/www/html/core/Tracker/VisitExcluded.php(199): Piwik\DeviceDetector\DeviceDetectorFactory->makeInstance() #4 /var/www/html/core/Tracker/VisitExcluded.php(73): Piwik\Tracker\VisitExcluded->isNonHumanBot() #5 /var/www/html/plugins/CoreHome/Tracker/VisitRequestProcessor.php(104): Piwik\Tracker\VisitExcluded->isExcluded() #6 /var/www/html/core/Tracker/Visit.php(164): Piwik\Plugins\CoreHome\Tracker\VisitRequestProcessor->processRequestParams() #7 /var/www/html/core/Tracker.php(171): Piwik\Tracker\Visit->handle() #8 /var/www/html/core/Tracker/Handler.php(55): Piwik\Tracker->trackRequest() #9 /var/www/html/core/Tracker.php(151): Piwik\Tracker\Handler->process() #10 /var/www/html/core/Tracker.php(126): Piwik\Tracker->track() #11 /var/www/html/piwik.php(73): Piwik\Tracker->main() #12 /var/www/html/matomo.php(14): include('...') #13 {main} thrown in /var/www/html/vendor/matomo/device-detector/ClientHints.php on line 297

@tsteur tsteur transferred this issue from matomo-org/device-detector Dec 12, 2024
@liviuconcioiu
Copy link
Contributor

liviuconcioiu commented Dec 13, 2024

It was also reported here matomo-org/device-detector#7916.

There are bots/libraries that will send NULL for the user-agent and other client hints headers. I think it should be fixed in device-detector.

@sgiehl sgiehl self-assigned this Dec 13, 2024
@sgiehl sgiehl added this to the 5.3.0 milestone Dec 13, 2024
@sgiehl sgiehl closed this as completed Dec 16, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants