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

If there is no referer set (for example on page refresh) craft.app.request.referrer throws type casting error #4124

Closed
jripmeester opened this issue Apr 11, 2019 · 2 comments

Comments

@jripmeester
Copy link

Description

When you get the referer from craft.app.request.referrer and there is no referer it should return null. But the type casting only allows the function to return a string so it throws an error.

Return value of craft\web\twig\variables\Request::getUrlReferrer() must be of the type string, null returned

Steps to reproduce

  1. get referer from craft.app.request.referrer in your twig template
  2. refresh page

Additional info

  • Craft version: 3.1.19 (Pro)
  • PHP version: 7.1.27
  • OS version: Linux 3.10.0-862.14.4.el7.x86_64
  • Database driver & version: MySQL 5.5.5
  • Image driver & version: GD 7.1.27
  • Plugins & versions:
    • Contact Form 2.2.3
    • Contact Form Extensions 1.1.1
    • Contact Form Honeypot 1.0.2
    • Cookie Consent Banner 1.1.2
    • Craft Commerce 2.1.2
    • Image Resizer 2.0.4
    • Instant Analytics 1.1.0
    • Linkit 1.1.10
    • Logs 3.0.0
    • Mailchimp Subscribe v2.0.4
    • Mailgun 1.4.2
    • Mollie for Craft Commerce 2.0.1
    • Navigation 1.1.11
    • Redactor 2.3.2
    • SEOmatic 3.1.46
    • Video Embedder 1.1.1
    • VZ URL 2.1.1
@brandonkelly
Copy link
Member

Thanks for reporting that! Fixed for the next release.

Note that craft.request.getUrlReferrer()/craft.request.urlReferrer has been deprecated in Craft 3. You should be using craft.app.request.referrer instead.

@jripmeester
Copy link
Author

Thanks Brandon!

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