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

Error : Call to undefined function donatj\UserAgent\parse_user_agent() #2922

Closed
taver opened this issue May 22, 2020 · 9 comments
Closed

Error : Call to undefined function donatj\UserAgent\parse_user_agent() #2922

taver opened this issue May 22, 2020 · 9 comments
Labels

Comments

@taver
Copy link

taver commented May 22, 2020

I updated grav to version 1.6.25 just now and I get this error 500.

Here are the logs:

[2020-05-22 15:11:49] grav.CRITICAL: Call to undefined function donatj\UserAgent\parse_user_agent() - Trace: #0 /code/system/src/Grav/Common/Grav.php(538): Grav\Common\Browser->__construct(Object(Grav\Common\Grav)) #1 /code/vendor/pimple/pimple/src/Pimple/Container.php(118): Grav\Common\Grav->Grav\Common{closure}(Object(Grav\Common\Grav)) #2 /code/system/src/Grav/Common/Twig/Twig.php(204): Pimple\Container->offsetGet('browser') #3 /code/system/src/Grav/Common/Processors/TwigProcessor.php(24): Grav\Common\Twig\Twig->init() #4 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\TwigProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #5 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #6 /code/system/src/Grav/Common/Processors/AssetsProcessor.php(28): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #7 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\AssetsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #8 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #9 /code/system/src/Grav/Common/Processors/SchedulerProcessor.php(29): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #10 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\SchedulerProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #11 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #12 /code/system/src/Grav/Common/Processors/BackupsProcessor.php(28): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #13 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\BackupsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #14 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #15 /code/system/src/Grav/Common/Processors/TasksProcessor.php(59): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #16 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\TasksProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #17 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #18 /code/system/src/Grav/Common/Processors/RequestProcessor.php(52): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #19 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\RequestProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #20 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #21 /code/system/src/Grav/Common/Processors/ThemesProcessor.php(27): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #22 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\ThemesProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #23 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #24 /code/system/src/Grav/Common/Processors/PluginsProcessor.php(30): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #25 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\PluginsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #26 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #27 /code/system/src/Grav/Common/Processors/InitializeProcessor.php(95): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #28 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\InitializeProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #29 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #30 /code/system/src/Grav/Common/Processors/DebuggerProcessor.php(27): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #31 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\DebuggerProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #32 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #33 /code/system/src/Grav/Common/Processors/ErrorsProcessor.php(27): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #34 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\ErrorsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #35 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #36 /code/system/src/Grav/Common/Processors/LoggerProcessor.php(48): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #37 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\LoggerProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #38 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #39 /code/system/src/Grav/Common/Processors/ConfigurationProcessor.php(28): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #40 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\ConfigurationProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) #41 /code/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #42 /code/system/src/Grav/Common/Grav.php(272): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) #43 /code/index.php(54): Grav\Common\Grav->process() #44 {main} [] []

I have no idea where this error came from or what I can do about it. I just know it's from the update I committed.

@peca021
Copy link

peca021 commented May 27, 2020

Hey, @taver Did you get this error on the localhost?
Could you show how your composer.json looks?

@rhukster
Copy link
Member

If you updated via Git, then you will need to do:

composer install --no-dev

@mahagr
Copy link
Member

mahagr commented Jul 7, 2020

Closed due to inactivity.

@mahagr mahagr closed this as completed Jul 7, 2020
@xhs345
Copy link

xhs345 commented Sep 2, 2020

I had the same issue. Overwrote the composer.json and composer.lock with the latest downloaded version and ran composer install --no-dev to fix it

@mahagr
Copy link
Member

mahagr commented Sep 2, 2020

If you're using git, you just need to do something like this:

git pull
composer install --no-dev
´´´

That is something everyone should do automatically on any project cloned from a git repo :)

@xhs345
Copy link

xhs345 commented Sep 2, 2020

I'm not using git, just the downloaded version. It looks like the automatic update is corrupting files. Might be related to missing permissions. Have to dig into the logs a bit more

@mahagr
Copy link
Member

mahagr commented Sep 3, 2020

Keep me updated on what you find out. I'll reopen the issue.

@mahagr mahagr reopened this Sep 3, 2020
@Maybach91
Copy link

Just for your information: I was trying to use PHP 7.3 and set it in the composer.json after a composer update i got the mentioned error. Its using "donatj/phpuseragentparser": "~1.0", instead of 0.10 and there is one deprecation in 1.0: https://github.com/donatj/PhpUserAgent#upgrading-to-1

The new 1.* release does not break compatibility with 0.* and nothing need to change to upgrade. However, the global parse_user_agent is now deprecated; it has been replaced with the namespaced \donatj\UserAgent\parse_user_agent and functions exactly the same. You can easily replace any existing call to parse_user_agent with \donatj\UserAgent\parse_user_agent
In addition, 1.x adds a convenience object wrapper you may use should you prefer. More information on this is in the Usage section below.

So maybe @taver was trying to run it with PHP 7.3 🤷 But its just guess. :)

@mahagr
Copy link
Member

mahagr commented Nov 12, 2020

That may be the case.

@mahagr mahagr closed this as completed Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants