I've noticed that sometimes there is an error logged saying: InvalidArgumentException: Cannot redirect to an empty URL. in Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl() (line 91 of /var/www/html/production/vendor/symfony/http-foundation/RedirectResponse.php).

This is happening due to goBack function because $this->redirectDestination is sometimes empty.

Comments

mkrizaj created an issue. See original summary.

mkrizaj’s picture

StatusFileSize
new591 bytes

Created a fix for this.

mkrizaj’s picture

StatusFileSize
new771 bytes

Adding correct patch with Url use.

mkrizaj’s picture

Status: Active » Needs review
hkirsman’s picture

StatusFileSize
new1.95 KB

Thanks, @mkrizaj!

Hm, I guess this fails sometimes in our code:

Url::fromRoute('<current>')->toString()

But I agree it should not give any error if it's missing.

About the patch "?destination=" would give empty string and the isset() check would pass, still failing with "InvalidArgumentException: Cannot redirect to an empty URL"

I looking at the class and not sure why I've added constructor there. Maybe it's leftover?

Here's my suggestion.