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

PHP 8.1 parse_str() warning #223

Open
ilianiv opened this issue Feb 4, 2022 · 1 comment
Open

PHP 8.1 parse_str() warning #223

ilianiv opened this issue Feb 4, 2022 · 1 comment

Comments

@ilianiv
Copy link
Contributor

ilianiv commented Feb 4, 2022

Warning:
parse_str(): Passing null to parameter No1 ($string) of type string is deprecated

File:
.../vendor/snowplow/referer-parser/php/src/Snowplow/RefererParser/Parser.php:53

public function parse($refererUrl, $pageUrl = null)
    {
        $refererParts = static::parseUrl($refererUrl);
        if (!$refererParts) {
            return Referer::createInvalid();
        }

        $pageUrlParts = static::parseUrl($pageUrl);

        if ($pageUrlParts
            && $pageUrlParts['host'] === $refererParts['host']
            || in_array($refererParts['host'], $this->internalHosts)) {
            return Referer::createInternal();
        }

        $referer = $this->lookup($refererParts['host'], $refererParts['path']);

        if (!$referer) {
            return Referer::createUnknown();
        }

        $searchTerm = null;
        if ($referer['parameters']) {
            parse_str($refererParts['query'], $queryParts);
                      ^^^
            foreach ($referer['parameters'] as $parameter) {
                $searchTerm = isset($queryParts[$parameter]) ? $queryParts[$parameter] : $searchTerm;
            }
        }

        return Referer::createKnown($referer['medium'], $referer['source'], $searchTerm);
    }
@TheMY3
Copy link

TheMY3 commented Sep 28, 2022

Can somebody update source code or approve PR if I create it?

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

No branches or pull requests

2 participants