Skip to content

FrontendUtility::getDomainFromUri() returns NULL when referer not set, but must return string #614

@pggns

Description

@pggns

We get the following error 50 - 60 times a day:

Core: Exception handler (WEB): Uncaught TYPO3 Exception: Return value of In2code\Powermail\Utility\FrontendUtility::getDomainFromUri() must be of the type string, null returned | TypeError thrown in file /var/www/vhosts/abitours.de/httpdocs/hub/public/typo3conf/ext/powermail/Classes/Utility/FrontendUtility.php in line 185. Requested URL: https://domain.tld/index.php?&type=1540053358&tx_powermail_pi1[language]=0&id=84&tx_powermail_pi1[pid]=84&tx_powermail_pi1[mobileDevice]=1&tx_powermail_pi1[referer]=&_=1601856000000

We are using Typo3 v10.4.9, Powermail v8.2.1 and PHP v7.3.23. Marketing Information is enabled, which seems to cause the error. The function breaks when there is no referer given:

/* Classes/Utility/SessionUtility.php Line 101 in function storeMarketingInformation() */
'refererDomain' => FrontendUtility::getDomainFromUri($referer),

/* Classes/Utility/FrontendUtility.php Line 182:
public static function getDomainFromUri(string $uri): string
{
  $uriParts = parse_url($uri);
  return $uriParts['host'];
}

The function getDomainFromUri() is forced to return a string, but if $referer is an empty string, $urlParts doesn't contain the host. So the function returns NULL instead of a string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions