Amasty Shopby 2.18.5 Webservice calls without a Http User Agent specified in the header results in a (500) Server Error.

Amasty Shopby 2.18.5 Webservice calls without a Http User Agent specified in the header results in a (500) Server Error.

Hello,

We recently discovered this issue when testing API calls from external web services.

The source of this error is this interceptor (plugin):
vendor/amasty/shopby/Plugin/Framework/App/PageCache/Identifier.php

  1.  
    /**
    *
    @param \Magento\Framework\App\PageCache\Identifier $subject
    * @param string $result
    * @return string
    * @SuppressWarnings(PHPMD.UnusedFormalParameter)
    */
    public function afterGetValue(\Magento\Framework\App\PageCache\Identifier $subject, $result)
    {
    if ($this->config->getType() == \Magento\PageCache\Model\Config::BUILT_IN && $this->config->isEnabled()) {
    $userAgent = $this->request->getServer('HTTP_USER_AGENT');
    $mobileAgentsPattern = implode('|', self::$mobileAgents);
    $pattern = '/(' . $mobileAgentsPattern . ')/i';
    if (preg_match($pattern, $userAgent)) {
    $result = self::IDENTIFIER_PREFIX . $result;
    }
    }

    return $result;
    }
In this method, preg_match is used where the variable $userAgent can potentially be null, in the later versions of PHP this method no longer accepts null values for the second parameter and will throw an error.