I'm getting it again and I nailed this down by finding another bug.
I have the a chunk with the following:
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
[[*using_accordion:is=`yes`:then=`[[$accordion_script]]`]]
...
The using_accordion TV is a radio with one value 'yes' and the other is 'no'. If the page needs to do an accordion for content then it includes the jQuery UI script for it, otherwise not. Simple enough.
The above chunk causes the page to load twice. My snippet loads twice (and other stuff probably does too) and I get those
Cannot redeclare function-name() errors. I tried surrounding my functions and my entire snippet in
if(!function_exists(FUNCTION_NAME)){//code} but I either got that error or nothing at all.
OK, so if I remove that one line above which checks the TV, the errors go away. Replace the line and the errors return.
Here's the weird part. If I replace the line as a comment and even bust it up, it still returns an error:
<!-- [ [ *using_ accordion:is=`yes`:then=`[ [ $accordion_script ] ] `] ] -->
I even got malicious with it and I still got errors:
<!-- [x [x * using_accordion :is=`yes`:then=`[x [x $ accordion_script ] x]`] x] -->
Note: It shouldn't even be processing that line.
If I just put a space before :then, it stops parsing what's in the comment - or at least it stops throwing errors.
And the Fix: If I add an else clause, all of the problems go away!
[[*using_accordion:is=`yes`:then=`[[$accordion_script]]`:else=``]]
The documentation shows an example without the else clause. This is clearly a bug somewhere in the parsing - and it's amazing that it would continue to parse that malicious code.
I believe others can stumble on this as I did. I'd like to get this in the issue list. The good news (as far as I can see now) is that there is now a documented solution.
NOW... To the original problem. I reported that some exception was causing my code to execute twice. This is yet another example of that. When the parser finds a :then without a :else (in this case) it must be throwing an error. That is uncaught, causing my snippet to execute twice, causing the
Cannot redeclare function-name() error. That's another issue that I'd like to get into the tracker, now that I've found a couple ways to reproduce it.
HTH