News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Problem with quotes inside reply posts

Started by kesulin, June 18, 2019, 06:32:12 AM

Previous topic - Next topic

kesulin

Hi everyone,

I have the same problem as this guy:

https://www.simplemachines.org/community/index.php?topic=528844.msg3753125#msg3753125

Quote
Recently I have a problem with my SMF forum. When you view a topic and read user's posts, you can click "quote" to make a quoted post. BUT - and here is the problem - when you view a topic and click REPLY to post a reply, then when scrolling down to view other posts and click Insert Quote... nothing happens. There is no code going in the text field of my reply and that means nobody can make quotes inside a reply.

I have not made any changes and this occurred suddenly. Any thoughts?

I can't find any solution for this, and I don't want uninstall any mod because most of them required fix some bugs for my SMF versión. I need some explanation about how InsertQuoteFast function works and where would be the bug.

Thanks in advance.

I running SMF 2.0.15.

Mods installed:
1.   SMF 2.0.X - PHP 7.2+ Compatibility   1.3
2.   Dice Roller BBcode   1.3     
4.   Ohara YouTube Embed   1.2.10
5.   Tapatalk SMF 2.0 Plugin   4.5.2
6.   Spoiler Tag   0.7.2a
7.   Tabbed smileys   0.3.7
9.   Menu_Icons   1.0 
10.   Board Icons   1.0 
11.   Random BBCode   2.0.0 
12.   Downloads System   3.0.4c
13.   Favicon   1.3     
14.   SMFPacks Shoutbox   1.1
15.   SA Chat   1.0a1 Rev120
16.   Hall Of Fame   1.2     
17.   Say Thanks   1.3.6     
19.   Member NotePad   2.0.3 
22.   Custom BBCodes Manager   2.8 
23.   Post and PM Inline Attachments   6.15 
24.   Recent Topics by 24h 48h 72h Filter   1.0 
25.   List aleatoria   2.0.0     
28.   BBCode with style   1.5.1
29.   RandomG BBCode   2.0.0
30.   Post Scheduler   1.0.1 
31.   Previous and Next Links for Page Index   2.1.204     
33.   Bot Recuento   1.0.0     
34.   Bot Guardar   1.0.0     
35.   Bot Mazo de cartas   1.0.0 

kesulin

I have the Post.template.php like original.

function insertQuoteFast(messageid)
{
if (window.XMLHttpRequest)
getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';xml;pb=', $context['post_box_name'], ';mode=\' + (oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled ? 1 : 0), onDocReceived);
else
reqWin(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';pb=', $context['post_box_name'], ';mode=\' + (oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled ? 1 : 0), 240, 90);
return true;
}
function onDocReceived(XMLDoc)
{
var text = \'\';
for (var i = 0, n = XMLDoc.getElementsByTagName(\'quote\')[0].childNodes.length; i < n; i++)
text += XMLDoc.getElementsByTagName(\'quote\')[0].childNodes[i].nodeValue;
oEditorHandle_', $context['post_box_name'], '.insertText(text, false, true);
}


I try to debug javascript with Chrome, enter insertquotefast but never arrive at OnDocRecieved.
I try to change theme too, but still no works. Then, I think this file is ok and bug is in another place.

I need help with it, no idea where is the problem.

Thanks,

Kindred

You have several mods which may be interfering with javascript...

you also have the 7.2 mod installed.... I don't think php is the problem... but SMF doesn't officially support php 7.2, so if that's the problem, you may have other issues as well
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

drewactual

jQuery conflicts... I've been fighting it for a while.  At some point I fully intend to migrate to latest while addressing the changes from stem to stern with both SMF, WP, AND jQuery... I was told several times by a premium SMF provider they used noConflict in their script- but- there are plenty of conflicts... to be fair, using mods or themes from other providers may not be helping either... 

are you using a theme or have a plugin or mod that calls to another version of jQuery? If so, unless noConflict is used properly, you're gonna have some funky behavior from the scripts running. (hint: #14).  now you can comment out a particular line and force the intended quote to take the user to the 'full' comment page, but.... that is a hack, and something i'm thinking was the beginning of the issues both of us are facing in the first place.  the solution is to use jQuery migrate and top off all the jQueries into one call- which will make your page faster WHILE it fixes your issues.

kesulin

Thanks for the comment. I try to install a new installation in a subdominion of my server:
http://test.castronegro.net/index.php

Just installed I try "insert quote" and no works. But then install mod php 7.2 compatibility and now works.
We are comparing the files between installations to find the problem. When I find it return here with the solution.

kesulin

The problem is "getXMLDocument" function not trigger "onDocReceived" function.
How it works?

Both function ara the same in both installations, any change on this code. How is posible?

kesulin

Quote from: kesulin on June 19, 2019, 04:31:17 AM
The problem is "getXMLDocument" function not trigger "onDocReceived" function.
How it works?

Both function ara the same in both installations, any change on this code. How is posible?
Well, GetXmlDocument not trigger OnDocRecieved because xml is null. I try get the url and no works

Please, see the error:
http://castronegro.net/index.php?action=quotefast;quote=1342;xml;pb=message;mode=0

In the new installation it works:
http://test.castronegro.net/index.php?action=quotefast;quote=1;xml;pb=message;mode=0

Then, the problem are in xml construct, I think the constructor write two times xml declaration. Well, Where xml constructs? Someone knows it?

kesulin

Quote from: kesulin on June 19, 2019, 04:51:57 AM
Then, the problem are in xml construct, I think the constructor write two times xml declaration. Well, Where xml constructs? Someone knows it?
I think the code is in Post.php. But the "quoteFast" function is exactly the same in both installations, then I am lose again.

kesulin

I find two templates in Xml.template.php

function template_quotefast()
{
global $context, $settings, $options, $txt;

echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '>
<smf>
<quote>', cleanXml($context['quote']['xml']), '</quote>
</smf>';
}

function template_modifyfast()
{
global $context, $settings, $options, $txt;

echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '>
<smf>
<subject><![CDATA[', cleanXml($context['message']['subject']), ']]></subject>
<message id="msg_', $context['message']['id'], '"><![CDATA[', cleanXml($context['message']['body']), ']]></message>
</smf>';

}


Both functions are the same in new installation.

Another function I find is "template_quotefast" in Post.template.php, without changes too.

Any idea where is the problem?

kesulin

I try in Internet explorer, in this browser I can see the xml message:
Quote
<?xml version="1.0" encoding="UTF-8"?>
<smf>
   <quote>
Quote from: admin on June 13, 2019, 10:59:02 AM
[mazo=nombre]contenido[/mazo]
</quote>
</smf>

There are a blank line before xml declaration. This is the problem. Where SMF construct xml message?

kesulin

Ok, ¡I find the bug!

No problem with xml constructor, no problem with xml templates. The bug are empty line before php declaration in Subs.php

One mod installed wrong and add text before php declaration. I fix it but remain empty line before. Insert quote use this to xml message and add this empty line before the xml message.

Some admin can close this. Thanks.

Advertisement: