Issue #3414889: Fixed WSOD TypeError when 'User Agent' is NULL by providing an...
https://www.drupal.org/project/universal_device_detection/issues/3414889
Fixed WSOD TypeError when User Agent
is NULL
, by providing the default string value unknown
.
Fixes the error:
TypeError : DeviceDetector\DeviceDetector::__construct(): Argument #1 ($userAgent) must be of type string, null given, called in /universal_device_detection/src/Detector/DefaultDetector.php on line 51 dans DeviceDetector\DeviceDetector->__construct() (ligne 188 de /vendor/matomo/device-detector/DeviceDetector.php).
Execute the following code on the development site to test this patch: dpm
with devel
:
use Drupal\universal_device_detection\Detector\DefaultDetector;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Request;
// Create a Symfony GET HTTP request with a NULL 'User-Agent'.
$request = Request::create('/', 'GET', [], [], [], ['HTTP_USER_AGENT' => NULL]);
$stack= new RequestStack();
$stack->push($request);
dpm($stack);
// Trigger detection to display error.
$default_detector = new DefaultDetector($stack);
$res = $default_detector->detect();
dpm($default_detector);
dpm($res);
Edited by David Suissa