ElkArte Community

Project Support => Support => Topic started by: lordmortimer on January 28, 2021, 06:56:59 pm

Title: Quote and Edit stopped working after moving to https
Post by: lordmortimer on January 28, 2021, 06:56:59 pm
Hello.

After moving to https I had several malfunctions in the forums, the worst of them being the "Quote" and "Quick Edit" buttons not working: the first one triggers the "Loading" window on the top, but it just never loads. The second one triggers the same loading window and it quickly goes away, but then I just can't edit anthing. It's like I never pressed the button.

I changed every url to https, including some I had to do manually, emptied the cache multiple times (both on the forums and my browser) and nothing. I don't know what to do anymore.

I have current Elk version and 7.3.26 PHP version. Mods installed: Optimus, Snow and Google Analytics Tracking.
Title: Re: Quote and Edit stopped working after moving to https
Post by: tino on January 28, 2021, 08:43:06 pm
I would download and run repair_settings to ensure that all the paths are updated. Do you get any errors in the console when clicking the link to edit/quote I would guess that’s where it’s failing.
Title: Re: Quote and Edit stopped working after moving to https
Post by: Spuds on January 29, 2021, 01:41:04 am
Missed your elk version, but hope is 1.1.x ... as @tino said repair settings may help.   Also open your browser console ,F12, and see if it tossing out some errors which may help in diagnosing the problem.
Title: Re: Quote and Edit stopped working after moving to https
Post by: lordmortimer on January 29, 2021, 05:08:04 pm
@Spuds 1.1.6
I tried to run repair_settings but it gets me a 403 error. Should I change permissions? If yes, to what?

From console:
Code: [Select]
 Uncaught TypeError: Cannot read property 'new_from_last' of undefined      desktop-notify.js?R116:337
    at Object.send (desktop-notify.js?R116:337)
    at send (script_elk.js?R116:1504)
    at Object.<anonymous> (script_elk.js?R116:1517)
    at i (jquery-3.1.1.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-3.1.1.min.js:2)
    at A (jquery-3.1.1.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery-3.1.1.min.js:4)
Title: Re: Quote and Edit stopped working after moving to https
Post by: Spuds on January 29, 2021, 06:59:18 pm
That 403 is more likely I need to check repair settings compatability with php 7.3/7.4 .... let me take a look at that first.
Title: Re: Quote and Edit stopped working after moving to https
Post by: Spuds on January 29, 2021, 09:04:11 pm
Did a quick check and it seems fine on 7.4.  Make sure you are using the one from: https://github.com/elkarte/tools/tree/master/repair_settings

and that you put it in the root of you forum. 
Title: Re: Quote and Edit stopped working after moving to https
Post by: lordmortimer on January 30, 2021, 05:41:57 pm
Using it but still get the 403 error.
Title: Re: Quote and Edit stopped working after moving to https
Post by: emanuele on January 30, 2021, 07:06:53 pm
For the reference, since the same question was asked on the SMF Italian forum too at:
https://www.italiansmf.net/forum/index.php?topic=2903.0
what I've seen there is that the XML returns a wrong content-type (html instead of xml), so the responseXML is null and the js code doesn't do its job.
TBH I'm not sure what it could cause that, but I don't remember breaking so badly the code, so I assume it could be some server configuration. shrugs
Title: Re: Quote and Edit stopped working after moving to https
Post by: lordmortimer on February 02, 2021, 06:04:55 pm
Quote from: Spuds – That 403 is more likely I need to check repair settings compatability with php 7.3/7.4 .... let me take a look at that first.
Guess it wasn't then.

After upload it has the 644 permissions code (meaning reading and writing available for the user, but not execute, while world and group only have the read one).
Title: Re: Quote and Edit stopped working after moving to https
Post by: Spuds on February 03, 2021, 03:27:52 am
Do you have a website address that shows what issue you are having, PM me if you want.

Did you try 664 or simply 777 (since its not like you are going to, or ever should, leave that file on the server)

Title: Re: Quote and Edit stopped working after moving to https
Post by: lordmortimer on February 06, 2021, 01:14:21 am
So, we managed to solve it by modifying script.js and adding this line in a bunch of functions.

For the Quote button
Code: [Select]
function getXMLDocument(sUrl, funcCallback)
{
var oMyDoc = new XMLHttpRequest(),
bAsync = typeof(funcCallback) !== 'undefined',
oCaller = this;

oMyDoc.overrideMimeType('text/xml');

Quick Edit
Code: [Select]
function sendXMLDocument(sUrl, sContent, funcCallback)
{
var oSendDoc = new window.XMLHttpRequest(),
oCaller = this;

oSendDoc.overrideMimeType('text/xml');

Forgot to tell that the "Mark all mex as read" at the bottom shows issues too (it works but the "Loading..." bar on top never goes away). What should I modify?
Title: Re: Quote and Edit stopped working after moving to https
Post by: Spuds on February 06, 2021, 02:12:05 am
To note, the fundamental problem is that the server is responding with type text/html instead of text/xml for xml / xhr responses   That means most any ajax call is being returned wrong.  I provided a fix for a couple of areas but I would suspect that most ajax calls will get mangled.

I found a workaround for using oSendDoc.overrideMimeType('text/xml'); to tell JS to still interpret the incorrect response as an XML Document and not text.  So that will fix several areas but there are more.

This is a bit like a server sending an image file back as text instead of binary and hoping the receiving program can figure it out  :D

If someone knows Apache, maybe you can provide some thoughts as to why it would be sending things back wrong?  I have not used Apache in so long that I'm really not that familiar with its setup, I do remember that the mime types used to be in a file mime.types but thats about all.
Title: Re: Quote and Edit stopped working after moving to https
Post by: augras on December 18, 2021, 12:45:15 pm
Hi,
I have the same problem on my main forum.
On my test forum i just have the "Loading..." bar on top that quick disapear but it works.
Twice on the same server with php 7.4 and 1.1.8 elkarte.
I have made nothing at this time to try to solve the problem.
I'm on https from a long time and i don't know if there is something with that.
Philippe
Title: Re: Quote and Edit stopped working after moving to https
Post by: augras on December 18, 2021, 02:12:12 pm
I tried the repair-settings.php (the one here : on github it seems to be 5 years old) : but everythings where ok.
Title: Re: Quote and Edit stopped working after moving to https
Post by: Spuds on December 18, 2021, 10:36:21 pm
Did it just stop working or did you do an update the site or the forum software? 
Title: Re: Quote and Edit stopped working after moving to https
Post by: augras on December 19, 2021, 10:04:43 am
Hi @Spuds ,
I have updated from 1.1.7 a few months ago and don't see anything : but my forum is small with not a lot of users.
Few days ago i have updated UltimateMenu with your new zip : i tried to uninstall but still the same problem.
I will install a new elkarte and UltimateMenu to test.
Title: Re: Quote and Edit stopped working after moving to https
Post by: augras on December 19, 2021, 10:26:29 am
I just made a fresh install : just french langpack and UltimateMenu... everything works fine !
Title: Re: Quote and Edit stopped working after moving to https
Post by: augras on December 19, 2021, 10:51:16 am
I forgot to say that just with elkarte alone, without addons and french langpack, i have the "Loading..." bar on top that quick disapear, like in my "official" test forum.
And here, in this forum, it is the same thing : is it regular ?
I don't remember that.
Title: Re: Quote and Edit stopped working after moving to https
Post by: Spuds on December 19, 2021, 03:50:14 pm
The loading bar only shows when its doing a AJAX call in the background.   If the call happens fast (as it should) it probably would just flash.  Something that should be improved in2.0 so its less annoying.
Title: Re: Quote and Edit stopped working after moving to https
Post by: augras on December 19, 2021, 03:59:06 pm
Of course, but what about Quote and Quick edit on my main forum : they don't work at all.
Do you have an idea ?
Title: Re: Quote and Edit stopped working after moving to https
Post by: augras on December 20, 2021, 02:01:46 pm
Hi,
There are some informations in chrome console.

With Quick edit button the console return :

Uncaught TypeError: XMLDoc.getElementsByTagName is not a function
    at QuickModify.onMessageReceived (topic.js?R118:412)
    at XMLHttpRequest.oSendDoc.onreadystatechange (script.js?R118:95)
QuickModify.onMessageReceived @ topic.js?R118:412
oSendDoc.onreadystatechange @ script.js?R118:95
XMLHttpRequest.send (async)
sendXMLDocument @ script.js?R118:102
QuickModify.modifyMsg @ topic.js?R118:399
onclick @ VM126 index.php:463

With Quote button the console returm:

Uncaught TypeError: oXMLDoc.getElementsByTagName is not a function
    at QuickReply.onQuoteReceived (topic.js?R118:294)
    at XMLHttpRequest.oMyDoc.onreadystatechange (script.js?R118:64)
QuickReply.onQuoteReceived @ topic.js?R118:294
oMyDoc.onreadystatechange @ script.js?R118:64
XMLHttpRequest.send (async)
getXMLDocument @ script.js?R118:69
QuickReply.quote @ topic.js?R118:278
onclick @ VM108 index.php:466

Philippe
Title: Re: Quote and Edit stopped working after moving to https
Post by: Spuds on December 21, 2021, 01:02:22 am
That seems like the same issue already discussed in this thread.  If the server does not send back an XML response then you get a failure.  You can test like this, on this site if you do:

https://www.elkarte.net/community/index.php?action=register;sa=usernamecheck;xml;username=testuser

You will get back an XML response like:
Code: [Select]
<elk>
<username valid="0">testuser</username>
</elk>

Do the same for your site, what do you get in the response? 

If its not the same then its a server configuration issue. 

One I have seen in the past is if your site sends back the response with content encoding br.  If that turns out to be the case it means your server is using the apache mod_brotli (only seen on an https sites)  And if that is so, you need to ensure you have Brotli  configured to send back the proper mime type.  Check that the Brotli configuration section has something like
RewriteRule "\.xml\.br$" "-" [T=text/xml,E=no-brotli:1,E=no-gzip:1]  
it could be there but set as text/html which is wrong.  Either way we need the response back as XML.  Good Luck
Title: Re: Quote and Edit stopped working after moving to https
Post by: augras on December 21, 2021, 09:48:23 am
Hi @Spuds ,

On my elkarte i get an error :

This page contains the following errors:
error on line 25 at column 6: XML declaration allowed only at the start of the document
Below is a rendering of the page up to the first error.
var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//augras.eu/matomo/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '5']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })();

Matomo is the point !
In this post i explain what i made to get matomo works :
https://www.elkarte.net/community/index.php?topic=6050.0

Matomo works but elkarte no !

I deleted the line
require 'matomo.php';
and now it works fine

Now i don't know how to make matomo working but Elkarte is on the road again.

THANK YOU @Spuds !