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

UAParser\Parser::parse() must be of the type string, null given #490

Open
VantianKaq opened this issue Apr 29, 2020 · 9 comments
Open

UAParser\Parser::parse() must be of the type string, null given #490

VantianKaq opened this issue Apr 29, 2020 · 9 comments

Comments

@VantianKaq
Copy link

Describe the bug
Whenever I try to do anything, including starting the server locally, I get:

In Parser.php line 35:
Argument 1 passed to UAParser\Parser::parse() must be of the type string, null given, called in D
:\Projects*****\vendor\pragmarx\tracker\src\Support\UserAgentParser.php on line 25

Removing the package, obviously, removes the error. But nothing else I have done (reinstall, clear cache, add package to non-discover, etc) has worked.
This literally started overnight with no configuration changes or packages updated, so I'm at a loss as to what to do. Any help would be greatly appreciated.

System

  • Laravel: 5.8.*
  • antonioribeiro /tracker: 3.5.0
@voicerecordist
Copy link

I get the same error
please help

@dikutandi
Copy link

dikutandi commented May 5, 2020

I thing There is an issue in the package that needs fixing to be able to work. The error occur when "composer dump-autoload" run. so I edited the pragmarx\tracker\src\Support\UserAgentParser.php and edit the construct method.

here my code

public function __construct($basePath, $userAgent = null)
    {
        $userAgent = $_SERVER['HTTP_USER_AGENT'];
        if (!$userAgent && isset($_SERVER['HTTP_USER_AGENT'])) {
            $userAgent = $_SERVER['HTTP_USER_AGENT'];
        }

        $this->parser = Parser::create()->parse($userAgent);

        $this->userAgent = $this->parser->ua;

        $this->operatingSystem = $this->parser->os;

        $this->device = $this->parser->device;

        $this->basePath = $basePath;

        $this->originalUserAgent = $this->parser->originalUserAgent;
    }

after that i run "composer dump-autoload" my self

dikutandi added a commit to dikutandi/tracker that referenced this issue May 5, 2020
dikutandi added a commit to dikutandi/tracker that referenced this issue May 5, 2020
@dikutandi
Copy link

I thing There is an issue in the package that needs fixing to be able to work. The error occur when "composer dump-autoload" run. so I edited the pragmarx\tracker\src\Support\UserAgentParser.php and edit the construct method.

here my code

public function __construct($basePath, $userAgent = null)
    {
        $userAgent = $_SERVER['HTTP_USER_AGENT'];
        if (!$userAgent && isset($_SERVER['HTTP_USER_AGENT'])) {
            $userAgent = $_SERVER['HTTP_USER_AGENT'];
        }

        $this->parser = Parser::create()->parse($userAgent);

        $this->userAgent = $this->parser->ua;

        $this->operatingSystem = $this->parser->os;

        $this->device = $this->parser->device;

        $this->basePath = $basePath;

        $this->originalUserAgent = $this->parser->originalUserAgent;
    }

after that i run "composer dump-autoload" my self

I change my code into this
$defaultUserAgent = 'Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0';

   ```

if (!$userAgent) {
$userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : $defaultUserAgent;
}

@felixbeer
Copy link

felixbeer commented May 7, 2020

So did this happen by a recent update? Cause editing vendor files can't really be more then a temp fix imo 😅

@namal-incubatelabs
Copy link

namal-incubatelabs commented May 11, 2020

I faced this issue while configuration caching. Thanks @dikutandi

@freddygenicho
Copy link

I am still facing the same issue. I have the latest update but the error persists after running
composer dumpautoload

@damonbakker
Copy link

Same issue. Just had the package installed on Laravel version 6.0.

@devInteam
Copy link

same here. laravel 7

@lucenarenato
Copy link

origamiv added a commit to origamiv/tracker that referenced this issue Aug 5, 2020
This was referenced Aug 5, 2020
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

9 participants