Tips & Tricks

Please do NOT use this section of the forum to request help if Joomdle does not work for you in some particular way. Your post will be deleted.

"Invalid Token" message causing a browser hang fix

  • Paul Johnson
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 7 months ago - 12 years 7 months ago #1 by Paul Johnson
To anyone having the "Invalid Token" message problem, I have attached a modified "plugins\user\joomdlehooks\joomdlehooks.php" file that fixes it. This problem manifests itself as a browser hang that repeatedly writes messages to the error log, filling it up. This hang is caused by an infinite loop due to some erroneous logic. The code is expecting a temporary file to be there that doesn't get written to.

The problematic logic was in the cURL requests. They did not include the Joomla token, so the request was not allowed, giving the "Invalid Token" message. Also, there were two requests when only one was necessary. I commented out the second request and added the token to the first. I had to change the CURLOPT_COOKIEFILE parameter to CURLOPT_COOKIEJAR as well to get the cURL request to actually write to the temporary file it was attempting to write to. Finally, the code to get the temp directory was flawed, as it wasn't looking for the correct Joomla temp directory. I fixed this as well.

Hopefully this helps someone else out, as it took me awhile to troubleshoot it.
Last edit: 12 years 7 months ago by Paul Johnson. Reason: Attachment didn't work

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago #2 by Antonio Durán
Replied by Antonio Durán on topic "Invalid Token" message causing a browser hang fix
Hi Paul.

Thank you very much for sharing your fixes. I will review them as soon as possible, to see if we can include them in the next release.

Antonio

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago #3 by Antonio Durán
Replied by Antonio Durán on topic "Invalid Token" message causing a browser hang fix
Hi Paul.

I don't understand this part:
>The problematic logic was in the cURL requests. They did not include the Joomla token, so the request was not allowed

The cURL request is made to Moodle, so I don't know what you would need the Joomla token for in there.


I have added your other changes. We rencently got a simiar bug report, here:
www.joomdle.com/en/forum/r09-support/102...oodle-function#13220

Please Log in or Create an account to join the conversation.

  • Paul Johnson
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 7 months ago #4 by Paul Johnson
Replied by Paul Johnson on topic "Invalid Token" message causing a browser hang fix
I was getting the message until I added the token. Our Moodle install is in a subdirectory of our Joomla site, so Joomla was intercepting the request before it moved on to Moodle. This is probably because we have SEO friendly URLs turned on, so Joomla just thought it was a Joomla task for itself due to the rewrite rules.

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago #5 by Antonio Durán
Replied by Antonio Durán on topic "Invalid Token" message causing a browser hang fix
Thanks for the additional info. I guess something must be different on your setup, as we have not received reports about this before. Do you have any SEF extension installed?

Please Log in or Create an account to join the conversation.

  • Paul Johnson
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 7 months ago #6 by Paul Johnson
Replied by Paul Johnson on topic "Invalid Token" message causing a browser hang fix
We are using the URL Rewrite module of IIS. So, http://<site>/<joomla stuff> is being converted to http://<site>/index.php/<joomla stuff> before it gets to Joomla. Joomla sees the cURL request as http://<site>/index.php/moodle<moodle stuff> and thinks it is for Joomla, so it needs the token. We could also get around this by changing our rewrite configuration.

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago #7 by Antonio Durán
Replied by Antonio Durán on topic "Invalid Token" message causing a browser hang fix
Thanks for the explanation.

As you say, I think it would be better to change the rewrite config, to exclude the moodle folder, instead of adding the change to the code.

Anyway, thanks again, I am sure this will help others in the future when they face the same problem.

Please Log in or Create an account to join the conversation.