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

Package does not work with Laravel 5.2, due to call to non-existant Request::userAgent() method #401

Closed
DivineOmega opened this issue Mar 22, 2018 · 3 comments · Fixed by #402
Assignees
Labels

Comments

@DivineOmega
Copy link
Contributor

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 5.2
Package version 6.0.1
PHP version 7.1.15

Actual Behaviour

When the package attempts get the request's user agent it fails, as the Request object that is a part of Illuminate/Http 5.2 does not contain a userAgent method.

The error received is:

BadMethodCallException in Macroable.php line 74: Method userAgent does not exist.

    in Macroable.php line 74
    at Request->__call('userAgent', array()) in Facade.php line 215
    at Facade::__callStatic('userAgent', array()) in UserAgentResolver.php line 26
    at UserAgentResolver::resolve()
    at call_user_func(array('OwenIt\Auditing\Resolvers\UserAgentResolver', 'resolve')) in Auditable.php line 334

Expected Behaviour

User agent for the request is successfully retrieved, and audit is correctly logged.

Steps to Reproduce

Attempt to create/update/delete a model, while using v6.0.1 of the package in Laravel 5.2 will reproduce the problem.

Possible Solutions

In order to maintain compatibility with Laravel 5.2, the resolve() method in the UserAgentResolver class will need to be modified to not use the non-existant Request::userAgent() method.

An alternative is to just use Request::header('User-Agent').

@quetzyg
Copy link
Contributor

quetzyg commented Mar 22, 2018

Thanks for spotting this out, @DivineOmega.

It is in fact an issue with Laravel versions below 5.4.

@DivineOmega
Copy link
Contributor Author

My pleasure.

@DivineOmega
Copy link
Contributor Author

Is the PR sufficient?

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

Successfully merging a pull request may close this issue.

2 participants