mautic / mautic

Mautic: Open Source Marketing Automation Software.
https://www.mautic.org
Other
7.26k stars 2.6k forks source link

Redirect URL not working after successful form submission #3936

Closed ServicedCloud closed 7 years ago

ServicedCloud commented 7 years ago

What type of report is this:

Q A
Bug report? Y
Feature request? N
Enhancement? N

Description:

We are in a process of updating our website from mautic from 2.7.1 to 2.8.0 in a development site. Then we've noticed that after successful form submission, redirect url doesn't work. Instead it goes to http://ourdevelopersite.com/form/submit?formId=19. Please note that we've cleared cached folder.

Q A
Mautic version 2.8.0
PHP version 5.6.24

Steps to reproduce:

  1. Create standalone form
  2. On Successful submit action; select > Redirect URL
  3. On Redirect URL/Message > fillup URL for example: https://ourdevelopersite.com/thankyou-page
gingerling commented 7 years ago

The redirect worked for me both in the preview and in a manually created html page. How are you displaying the form? I am using mautic.net, not sure what version that is, I would assume a tweaked version of the latest though.

ServicedCloud commented 7 years ago

Hi gingerling,

Thank you for your reply. We are using self-hosted mautic and displaying the form in a Joomla page. We recently made a trial update from 2.7.1 to 2.8.0 and found out that the Redirect URL is not working.

escopecz commented 7 years ago

Do you see any error in the logs or JS error in the console?

proggable commented 7 years ago

I am seeing this same issue on self-hosted Mautic installation, with the form displayed using the recommended automatic javascript option, within my own bespoke PHP generated page.

I am not seeing any error in the Mautic access or error logs or in the JS console, in browser.

proggable commented 7 years ago

I also get the same issue when I publish the form within a Mautic Landing Page and submit the form from there.

The action to submit the form by email fires okay. Just the URL redirection fails.

ServicedCloud commented 7 years ago

We have this error in the JS console

Failed to load resource: the server responded with a status of 404 (not found) - mautic-form.js

Then nothing in the log file.

escopecz commented 7 years ago

Ok. I think it's the same issue as https://github.com/mautic/mautic/issues/3848.

proggable commented 7 years ago

I don't seem to have the issue with mautic-form.js throwing a 404, not found.

The mautic-form.js content seems to load fine to my browser. But I get the URL redirection failure, nonetheless.

proggable commented 7 years ago

I am running Mautic 2.8.0, PHP 7.0.

proggable commented 7 years ago

I can confirm that the "Display Message" option does not work either.

I've dug a bit more into what is happening and I can see that the "Submit" action for the form, with URL /form/submit?formId=1 is giving me a Mautic 403 Forbidden page.

Does that help narrow it down? Or is that just because GET is blocked for that form submit URL?

ServicedCloud commented 7 years ago

I checked out the solution #3848 mentioned by escopecz and it somehow gives me the hint on what is going on. The path for mautic-form.js is incorrect, it looks duplicated and throws both the live site and dev site url. I added "http" in the site url of our dev site and cleared the cache folder, checked out and the redirect url is now working.

Please note that in the previous version, we did not add any "http" in the site url of our development site and still the redirect url works smoothly.

Thank you for your fast response on this.

proggable commented 7 years ago

I have the full https:// prefix specified in the Mautic site URL.

In terms of the post-submission form redirect, I am redirecting to a page on the same remote site that I am embedding the Mautic form to. So again, in the Mautic form config, the full URL path is entered, including the https:// prefix.

However, for me, as well the URL redirection option not working, the "display message" option doesn't work either.

proggable commented 7 years ago

The issue is the same though, too, if I embed the form in a Mautic Landing Page and redirect to another Mautic Landing page.

I've also now tried with both Standard and Campaign type forms (as my initial issue was with a campaign type form). Issue is the same in all cases. The form action, to send the results as an email, works. However, after that, the "URL redirection" or "display message" options don't.

proggable commented 7 years ago

Below is an extract from my Mautic error log.

I suspect the first RssAtomBundle ERROR is occurring on loading the Mautic dashboard page, or on initial log in to the control panel.

The NOTICE entries that follow are on loading the form, as far as I can tell. Might these give a clue to what is going wrong?

[2017-05-03 08:46:03] mautic.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined function Debril\RssAtomBundle\Driver\curl_init() - in file /var/www/mautic/vendor/debril/rss-atom-bundle/Debril/RssAtomBundle/Driver/HttpCurlDriver.php - at line 54 [] [] [2017-05-03 09:11:26] mautic.NOTICE: PHP Notice - Undefined index: app_id - in file /var/www/mautic/app/bundles/NotificationBundle/Helper/NotificationHelper.php - at line 116 [] [] [2017-05-03 09:11:26] mautic.NOTICE: PHP Notice - Undefined index: safari_web_id - in file /var/www/mautic/app/bundles/NotificationBundle/Helper/NotificationHelper.php - at line 117 [] [] [2017-05-03 09:11:26] mautic.NOTICE: PHP Notice - Undefined index: subdomain_name - in file /var/www/mautic/app/bundles/NotificationBundle/Helper/NotificationHelper.php - at line 119 [] [] [2017-05-03 09:13:31] mautic.NOTICE: PHP Notice - Undefined index: app_id - in file /var/www/mautic/app/bundles/NotificationBundle/Helper/NotificationHelper.php - at line 116 [] [] [2017-05-03 09:13:31] mautic.NOTICE: PHP Notice - Undefined index: safari_web_id - in file /var/www/mautic/app/bundles/NotificationBundle/Helper/NotificationHelper.php - at line 117 [] [] [2017-05-03 09:13:31] mautic.NOTICE: PHP Notice - Undefined index: subdomain_name - in file /var/www/mautic/app/bundles/NotificationBundle/Helper/NotificationHelper.php - at line 119 [] []

escopecz commented 7 years ago

I see. Try to install/enable PHP CURL extension on your server and restart the server. Let us know if it worked.

proggable commented 7 years ago

Okay - installing and enabling PHP CURL extension has fixed my Mautic Dashboard - thanks! Silly of me not to have checked that was installed.

The URL redirection issue still remains, for the form, though.

escopecz commented 7 years ago

The other PHP notices in your log are fixed in https://github.com/mautic/mautic/pull/3965. Could you give it a test if it solves the form redirect issue?

proggable commented 7 years ago

I've applied the modified NotificationHelper.php file, from #3965 to my Mautic build.

Cleared Mautic app cache (and restarted Apache2 and cleared browser cache for good measure).

It hasn't resolved the URL redirection issue. I still get the following in the log, when accessing and submitting the form:

[2017-05-03 10:17:09] mautic.NOTICE: PHP Notice - Undefined index: app_id - in file /var/www/mautic/app/bundles/NotificationBundle/Helper/NotificationHelper.php - at line 116 [] [] [2017-05-03 10:17:09] mautic.NOTICE: PHP Notice - Undefined index: safari_web_id - in file /var/www/mautic/app/bundles/NotificationBundle/Helper/NotificationHelper.php - at line 117 [] [] [2017-05-03 10:17:09] mautic.NOTICE: PHP Notice - Undefined index: subdomain_name - in file /var/www/mautic/app/bundles/NotificationBundle/Helper/NotificationHelper.php - at line 119 [] [] [2017-05-03 10:18:18] mautic.NOTICE: PHP Notice - Undefined index: username - in file /var/www/mautic/app/bundles/SmsBundle/Api/TwilioApi.php - at line 59 [] [] [2017-05-03 10:18:18] mautic.NOTICE: PHP Notice - Undefined index: password - in file /var/www/mautic/app/bundles/SmsBundle/Api/TwilioApi.php - at line 59 [] [] [2017-05-03 10:18:23] mautic.NOTICE: PHP Notice - Undefined index: username - in file /var/www/mautic/app/bundles/SmsBundle/Api/TwilioApi.php - at line 59 [] [] [2017-05-03 10:18:23] mautic.NOTICE: PHP Notice - Undefined index: password - in file /var/www/mautic/app/bundles/SmsBundle/Api/TwilioApi.php - at line 59 [] []

escopecz commented 7 years ago

I made an update to that PR. Could you please test again?

proggable commented 7 years ago

Many thanks - I've applied the updated PR and now only get that Twilio username and password undefined index message in the logs, from TwilioApi.php (I don't have the Twilio plugin set up, by the way). See log message below.

The post form submission URL redirection is still not working.

But the logs are clear of those NotificationHelper.php notices.

[2017-05-03 13:28:26] mautic.NOTICE: PHP Notice - Undefined index: username - in file /var/www/mautic/app/bundles/SmsBundle/Api/TwilioApi.php - at line 59 [] [] [2017-05-03 13:28:26] mautic.NOTICE: PHP Notice - Undefined index: password - in file /var/www/mautic/app/bundles/SmsBundle/Api/TwilioApi.php - at line 59 [] []

escopecz commented 7 years ago

Those notices are fixed in https://github.com/mautic/mautic/pull/3923. All should be fixed in 2.8.1 in several days, but if you can test with that one too, it'd help to fix your original issue.

proggable commented 7 years ago

No problem - thanks

I updated my build, with the revised app/bundles/NotificationBundle/Entity/Notification.php and app/bundles/SmsBundle/Api/TwilioApi.php from #3923, and my log is now clear of those last two undefined index notices - albeit the URL redirection issue remains.

RCheesley commented 7 years ago

I can confirm the same problem with the form submission URL's and seeing a duplicated sub-folder in the URL resulting in a 404 on the mautic-form.js.

proggable commented 7 years ago

I do not seem to be seeing the duplicated sub-folder or getting the 404 error for mautic-form.js

My Mautic installation is on it's own subdomain, with Mautic's index.php at the site root, in case that makes a difference.

I have had a further look at what was happening browser-side on form submission. I can see that the hidden input mauticform[return] is being populated with the URL of the page in which the form is embedded, after I press the submit button. Either my own PHP page, or the Mautic Landing Page (I am testing both options).

Is this the correct / expected behaviour?

RCheesley commented 7 years ago

It seems the people having this problem have Mautic in a sub-folder, so perhaps something is being misinterpreted when the response hits a '/' within the path of the Mautic instance and it is doing some kind of iteration/repetition of the contents after and including the '/' ?

proggable commented 7 years ago

I am getting the failed "URL redirection" issue, after form submit.

But not seeing the other issue with the 404 error for the mautic-form.js file.

proggable commented 7 years ago

Okay - that did give me an idea though.

I was seeing a duplicated URL issue, in my Apache2 access log, in fact.

When I had a further look there I spotted this:

[REDACTED_IP] - - [03/May/2017:16:36:16 +0100] "GET /form/generate.js?id=1 HTTP/1.1" 200 8490 "[REDACTED_URL]" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0" [REDACTED_IP] - - [03/May/2017:16:36:17 +0100] "GET /index.php/media/js/mautic-form.js HTTP/1.1" 301 837 "[REDACTED_URL]" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0" [REDACTED_IP] - - [03/May/2017:16:36:17 +0100] "GET /media/js/mautic-form.js HTTP/1.1" 200 5811 "[REDACTED_URL]" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0" [REDACTED_IP] - - [03/May/2017:16:36:17 +0100] "GET /index.php/media/css/modal.min.css HTTP/1.1" 301 837 "[REDACTED_URL]" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0" [REDACTED_IP] - - [03/May/2017:16:36:17 +0100] "GET /media/css/modal.min.css HTTP/1.1" 200 1224 "[REDACTED_URL]" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0"

Basically my Mautic Configuration->System Settings->General Settings->Site URL had "/index.php" appended to it.

I am using mod_rewrite, in my Apache2 virtual host config, to remove the index.php, because I am running Mautic on it's own sub domain.

This hadn't, it seems, been causing an issue in 2.7.1, but has certainly started to now, in 2.8.0

Removing the "/index.php" from the Mautic Site Url has now fixed the post-form-submit URL redirection issue for me.

RCheesley commented 7 years ago

Ah, cool! I'm on 2.7.1 still, and don't have /index.php on the site URL so guess they are un-related!

pdanshov commented 7 years ago

I've been having similar issues as well, I have mautic in a subfolder (/mautic) and the issue seems to be in the config section field where you specify the "Site URL" - if I put mydomain.com - the cron generated links do not work, but the email templates load up fine with images and all, but if I put (correctly in my opinion) mydomain.com/mautic (which is where my install is) - then the tracking and cron generated links work, but the email templates are missing all the images and in the source I see mydomain.com/mautic/mautic/....jpg etc...

I've tried different directories, and the same thing happens (mydomain.com/mautic2/mautic2/.....)

escopecz commented 7 years ago

There are several unrelated problems reported in this issue.

For those having problem with 404 on form JS, the problem can be:

  1. In configuration. See the troubleshooting.
  2. There is a bug in the generated URL when Mautic is installed in a subdirectory. The bug will be squashed in 2.9.1.

I'll close this. If none of the above solutions work for you, please create a new issue specific for your problem. I'm losing track of what is solved and what's not in the above comments.