PHP Fatal error: Cannot redeclare template_quotefast

Started by Black Tiger, December 09, 2014, 07:30:15 PM

Previous topic - Next topic

Black Tiger

It's not a big issue, but it's creating an error_log and I wonder what's the cause. This week it happened 3 times and this is the complete error_log:
[02-Dec-2014 10:42:01 Europe/Amsterdam] PHP Fatal error:  Cannot redeclare template_quotefast() (previously declared in /home/customer/public_html/forum/Themes/default/Xml.template.php:25) in /home/customer/public_html/forum/Themes/default/Post.template.php on line 1001
[05-Dec-2014 02:22:28 Europe/Amsterdam] PHP Fatal error:  Cannot redeclare template_quotefast() (previously declared in /home/customer/public_html/forum/Themes/default/Xml.template.php:25) in /home/customer/public_html/forum/Themes/default/Post.template.php on line 1001
[06-Dec-2014 08:33:18 Europe/Amsterdam] PHP Fatal error:  Cannot redeclare template_quotefast() (previously declared in /home/customer/public_html/forum/Themes/default/Xml.template.php:25) in /home/customer/public_html/forum/Themes/default/Post.template.php on line 1001


As you can see it's always the same files.
So I checked and line 25 in Xml.template.php states:
        global $context, $settings, $options, $txt;

Line 1001 in Post.template.php reads:
}

As far as I know, these files are both original files, they both dated June 6Th 2011 and I'm running SMF 2.0.9.
Mods installed:
1.    My Posts SMF2    1.2
2.    Redirection Topics    1.0.3
3.    SimplePortal    2.3.6
4.    Remove "Last edit" mod    0.2.5
5.    Downloads System    2.0
6.    Contact Page

As said, it's not a very big problem, just wondering why this is happening with default files (as far as I know).
Greetings, Black Tiger

Arantor

So what URL is being accessed when that error occurs?

Something is doing the posting - while the XML template is loaded, which is what causes the problem. But nothing comes to mind as to why the XML template should be loaded in that situation.

Bob Perry of Web Presence Consulting

yes, it is so a "big issue"... sort of, your users will not be able to use certain areas of your system until this is fixed, yes,  a link to your site please?

Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

Black Tiger

@Bob Perry: Sometimes I wonder if people here even do read what is written. I clearly stated =twice= that it's not a big issue, just something which makes me curious. So please explain why you make a doubtful comment about some big issue? Link is below.

@Arantor: I don't have a clue on that, sorry. I just find this in the forums error_log now and then.
http://www.satellitefun.org/forum is the url of the forums, but I don't know how to find out exactly how to reproduce the problem.
Greetings, Black Tiger

Arantor

Presumably something in the Apache access log, at the same timestamp, with status 500, to indicate the URL?

Black Tiger

I could use that, but the problem is that there was a log rotation on the 8Th so unfortunately I could'nt look it up.
But since it's not an issue, I can easily wait until it happens again in the forum log and look it up in the apache logs at that time. I'll keep you informed!
Greetings, Black Tiger

Black Tiger

Oke I managed to get the cause of the error notice. Looks like it has to do something with previews:
This is from the apache logfile:

First time it happened today at 18:10 hours:
[14/Dec/2014:18:10:56 +0100] POST /forum/index.php?action=post2;board=75;preview;xml HTTP/1.1" 500 26 "http://www.satellitefun.org/forum/index.php?action=post;board=75.0"

The second time with a slight difference at 18:11 hours:
[14/Dec/2014:18:11:38 +0100] POST /forum/index.php?action=post2;board=75;preview;xml HTTP/1.1" 500 26 "http://www.satellitefun.org/forum/index.php?action=post2;start=0;board=75"

I just checked and it's just a normal post, made by a new user. But it's also the only preview I can find in the log of today.
Greetings, Black Tiger

Arantor

Hmm, the URL's right and the path seems normal enough in terms of what it loads.

What mods are installed?

Black Tiger

These are the mods currently installed.
1.    My Posts SMF2    1.2
2.    Redirection Topics    1.0.3
3.    SimplePortal    2.3.6
4.    Optimus Brave    1.8.7
5.    Tapatalk SMF 2.0 Plugin
6.    Remove "Last edit" mod
7.    Global Headers Footers
8.    Birthday On Register
9.    Downloads System
10.    Contact Page

However, when this error occured for the first time it was only these mods installed:
1.    My Posts SMF2    1.2
3.    SimplePortal    2.3.6
6.    Remove "Last edit" mod
9.    Downloads System
10.    Contact Page
Greetings, Black Tiger

Black Tiger

Oh I've just seen I posted the mods already in my first question. ;)
Greetings, Black Tiger

Arantor

Hmmm, curious. Nothing on there except maybe SimplePortal could cause this and even then it still shouldn't :(

Black Tiger

It shouldn't indeed, but it does, however luckily only a very few times and it does no harm, so it's still not very important.

In that case I might go over there and ask if they have a clue.
Thanks!
Greetings, Black Tiger

David July

I am not running SimplePortal yet recently discovered the same "Cannot redeclare template_quotefast" error_log entries as Black Tiger reported, along with the corresponding "POST /index.php?action=post2;board=4;preview;xml HTTP/1.1" entry in the Apache access log.  The only mod installed is Menu Editor Lite (1.0.5).

The two most recent instances of the error were on 19 December 2014.  I determined that they both occurred for the same user, first when they started a new thread and second during their third reply in it.  That same user's other two replies as well as two replies by another user did not generate the error.

I have emailed the user to see if they experienced any usual behavior during this instance.  I anticipate they will report nothing out of the ordinary however, because I found an error entry that corresponds to a post I made and nothing strange happened then.

Given that nothing seems amiss with the operation of the forum, I appear to be in a similar situation as Black Tiger—curious but not particularly concerned.  I wanted to provide these details in case it helps.  Thanks.

Black Tiger

Thank you for sharing. However I can state the SimplePortal can not be the cause, because I'm having the same issue on another forum on the same server, which does not have Simpleportal installed.
Maybe this way we can narrow the problem somehow.
Greetings, Black Tiger

fun4us

Hello,
i have nearly the same issue here.

QuotePHP Fatal error:  Cannot redeclare template_quotefast() (previously declared in /data/www/mineralienatlas/htdocs/forum/Sources/Load.php(2172) : eval()'d code:25) in /.../forum/Sources/Load.php(2172) : eval()'d code on line 1001

It always happens while opening a message preview. Nothing bad seems to happen except the log entry.
Only mod highslide image viewer. SMF 2.0.9.

Any reason while it is marked to be closed without solution?
Cheers Stefan

fun4us

Post.template.php

Add the red lines and no more error.

if (!function_exists('template_quotefast')) {
function template_quotefast()
{
global $context, $settings, $options, $txt;

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
<title>', $txt['retrieving_quote'], '</title>
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js"></script>
</head>
<body>
', $txt['retrieving_quote'], '
<div id="temporary_posting_area" style="display: none;"></div>
<script type="text/javascript"><!-- // --><![CDATA[';

if ($context['close_window'])
echo '
window.close();';
else
{
// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;).
echo '
var quote = \'', $context['quote']['text'], '\';
var stage = \'createElement\' in document ? document.createElement("DIV") : document.getElementById("temporary_posting_area");

if (\'DOMParser\' in window && !(\'opera\' in window))
{
var xmldoc = new DOMParser().parseFromString("<temp>" + \'', $context['quote']['mozilla'], '\'.replace(/\n/g, "_SMF-BREAK_").replace(/\t/g, "_SMF-TAB_") + "</temp>", "text/xml");
quote = xmldoc.childNodes[0].textContent.replace(/_SMF-BREAK_/g, "\n").replace(/_SMF-TAB_/g, "\t");
}
else if (\'innerText\' in stage)
{
setInnerHTML(stage, quote.replace(/\n/g, "_SMF-BREAK_").replace(/\t/g, "_SMF-TAB_").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
quote = stage.innerText.replace(/_SMF-BREAK_/g, "\n").replace(/_SMF-TAB_/g, "\t");
}

if (\'opera\' in window)
quote = quote.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, \'"\').replace(/&amp;/g, "&");

window.opener.oEditorHandle_', $context['post_box_name'], '.InsertText(quote);

window.focus();
setTimeout("window.close();", 400);';
}
echo '
// ]]></script>
</body>
</html>';
}

}

Black Tiger

I don't know, I did not tick it solved and I was not notified that it would be set to solved.
If a moderator has a reason to put it to solved I'm sure they will tell us why. In the meantime I will put it to unsolved again, especially since more more forums having this issue.

Fun4us: Exactly where do I put that red line?

Next to that... if this is a solution, should this be fixed by the team in the core files?
Greetings, Black Tiger

fun4us

Hi,
in front and after the code in the code box. You will find the file Post.template.php in the Themes/default folder. There you will find the code from the box inside.

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

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
<title>', $txt['retrieving_quote'], '</title>
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js"></script>
</head>
<body>
', $txt['retrieving_quote'], '
<div id="temporary_posting_area" style="display: none;"></div>
<script type="text/javascript"><!-- // --><![CDATA[';

if ($context['close_window'])
echo '
window.close();';
else
{
// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;).
echo '
var quote = \'', $context['quote']['text'], '\';
var stage = \'createElement\' in document ? document.createElement("DIV") : document.getElementById("temporary_posting_area");

if (\'DOMParser\' in window && !(\'opera\' in window))
{
var xmldoc = new DOMParser().parseFromString("<temp>" + \'', $context['quote']['mozilla'], '\'.replace(/\n/g, "_SMF-BREAK_").replace(/\t/g, "_SMF-TAB_") + "</temp>", "text/xml");
quote = xmldoc.childNodes[0].textContent.replace(/_SMF-BREAK_/g, "\n").replace(/_SMF-TAB_/g, "\t");
}
else if (\'innerText\' in stage)
{
setInnerHTML(stage, quote.replace(/\n/g, "_SMF-BREAK_").replace(/\t/g, "_SMF-TAB_").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
quote = stage.innerText.replace(/_SMF-BREAK_/g, "\n").replace(/_SMF-TAB_/g, "\t");
}

if (\'opera\' in window)
quote = quote.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, \'"\').replace(/&amp;/g, "&");

window.opener.oEditorHandle_', $context['post_box_name'], '.InsertText(quote);

window.focus();
setTimeout("window.close();", 400);';
}
echo '
// ]]></script>
</body>
</html>';
}



and replace

if (!function_exists('template_quotefast')) {
function template_quotefast()
{
global $context, $settings, $options, $txt;

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
<title>', $txt['retrieving_quote'], '</title>
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js"></script>
</head>
<body>
', $txt['retrieving_quote'], '
<div id="temporary_posting_area" style="display: none;"></div>
<script type="text/javascript"><!-- // --><![CDATA[';

if ($context['close_window'])
echo '
window.close();';
else
{
// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;).
echo '
var quote = \'', $context['quote']['text'], '\';
var stage = \'createElement\' in document ? document.createElement("DIV") : document.getElementById("temporary_posting_area");

if (\'DOMParser\' in window && !(\'opera\' in window))
{
var xmldoc = new DOMParser().parseFromString("<temp>" + \'', $context['quote']['mozilla'], '\'.replace(/\n/g, "_SMF-BREAK_").replace(/\t/g, "_SMF-TAB_") + "</temp>", "text/xml");
quote = xmldoc.childNodes[0].textContent.replace(/_SMF-BREAK_/g, "\n").replace(/_SMF-TAB_/g, "\t");
}
else if (\'innerText\' in stage)
{
setInnerHTML(stage, quote.replace(/\n/g, "_SMF-BREAK_").replace(/\t/g, "_SMF-TAB_").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
quote = stage.innerText.replace(/_SMF-BREAK_/g, "\n").replace(/_SMF-TAB_/g, "\t");
}

if (\'opera\' in window)
quote = quote.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, \'"\').replace(/&amp;/g, "&");

window.opener.oEditorHandle_', $context['post_box_name'], '.InsertText(quote);

window.focus();
setTimeout("window.close();", 400);';
}
echo '
// ]]></script>
</body>
</html>';
}
}



This is a workaround to check if the function is loaded before and if it will not load again. So no more error. The fix whould be to find where the function is loaded twice and to remove this.

But both will work.
Cheers

Black Tiger

Oke thank you, this will bring some peace and quiet in the log file.

However I will leave this topic open for the moment (not solved), because it happens on forums with different mods. Maybe the specialist can have a clue on where it could be loaded twice.
Maybe this way it can really be fixed instead of a workaround.
Greetings, Black Tiger

Kindred

but it does not happen on a standard installation (and I have also installed over 200 mods on a system and never seen the issue)

So, it would seem to be some specific combination of mods...   but unlikely to be updated in the core, since it never happens to a clean installation.
Сл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."

Advertisement: