Invenzzia »

IMPORTANT ANNOUNCEMENT

Due to the uncertain status of the Flyspray project, lack of new releases and moving the code repository to Github, we decided to shutdown this issue tracker by the end of January 2011. From that date, the bugs should be reported directly in Github project repositories.

List of repositories:

Open Power Template 2.x family

PLEASE PROVIDE THE TEMPLATES AND/OR PHP CODE IN THE TASK DESCRIPTION (Not URL-s to them). THAT ALLOWS US TO REPRODUCE THE PROBLEM! OTHERWISE WE ARE NOT ABLE TO HELP YOU!

Remember to hide all the security-related pieces of code from the task description, like passwords, server paths etc. for your own safety. Once we close the task, we cannot edit it anymore!
Tasklist

FS#40 - Not detected recursion

Attached to Project: Open Power Template
Opened by Skruppy (Skrupellos) - Thursday, 08 January 2009, 08:58 GMT-8
Last edited by Zyx (Zyx) - Thursday, 22 January 2009, 08:06 GMT-8
Task Type Bug Report
Category Compiler
Status Closed
Assigned To Zyx (Zyx)
Operating System OS-independent
Severity Medium
Priority Normal
Reported Version 2.0-beta1
Due in Version 2.0-beta2
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Code:
--- CODE: a.tpl ---
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<opt:root>
<opt:include file="a.tpl" />
<opt:include file="a.tpl" />
</opt:root>
--- END a.tpl---

--- CODE: b.tpl ---
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<opt:extend file="b.tpl">
<opt:snippet name="slot">
Hello
</opt:snippet>
</opt:extend>
--- END b.tpl---

--- CODE: c.tpl ---
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<b>
<opt:insert snippet="slot">
</opt:insert>
</b>
--- END c.tpl---


Result:
Fatal error: Maximum function nesting level of '100' reached, aborting! in lib/Opt/Xml/Scannable.php on line 234

Call Stack
# Time Memory Function Location
1 0.0044 60520 {main}( ) ../gui1.php:0
2 0.0745 520880 Opt_Output_Http->render( object(Opt_View)[2], ??? ) ../gui1.php:20
3 0.0749 561996 Opt_View->_parse( object(Opt_Output_Http)[3], long, ???, ??? ) ../Http.php:202
4 0.6465 2897880 require( '.../cache/templates/a.tpl.php' ) ../Class.php:504
5 0.6477 2899876 Opt_View->_parse( object(Opt_Output_Http)[3], long, bool, bool ) ../a.tpl.php:3
6 0.7959 2934744 require( '.../cache/templates/a.tpl.php' ) ../Class.php:504
7 0.7972 2936080 Opt_View->_parse( object(Opt_Output_Http)[3], long, bool, bool ) ../a.tpl.php:3


Expected result:
<b>Hello</b>
<b>Hello</b>
This task depends upon

Closed by  Zyx (Zyx)
Thursday, 22 January 2009, 08:06 GMT-8
Reason for closing:  Fixed
Additional comments about closing:  The task was reopened just to hide some user paths in the description. Nothing strange.
Comment by Skruppy (Skrupellos) - Thursday, 08 January 2009, 09:29 GMT-8
Sorry, there was a mistake in my exaple. This is better:
--- CODE: a.tpl ---
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<opt:root>
<opt:include file="b.tpl" />
<opt:include file="b.tpl" />
</opt:root>
--- END a.tpl---

--- CODE: b.tpl ---
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<opt:extend file="c.tpl">
<opt:snippet name="slot">
Hello
</opt:snippet>
</opt:extend>
--- END b.tpl---



Now the result is: Opt_InheritanceRecursion_Exception

Expected result:
<b>Hello</b>
<b>Hello</b>

This happens when:
$tpl = new Opt_Class;
$tpl->compileMode = Opt_Class::CM_REBUILD; <-- the problem

Is it a bug or a feature?
Comment by Zyx (Zyx) - Thursday, 08 January 2009, 09:53 GMT-8
Yes, this is a bug, but related to the compiler cleaning up. If you have Opt_Class::CM_REBUILD, the template is compiled twice and the code did not remove information of the inheritance chain from the previous compilation.

Quick patch:

Opt/Compiler/Class.php, somewhere near line 1114 we have:

----
if($weFree)
{
// Do the cleanup.
self::$_recursionDetector = NULL;
}
----

Replace with:

----
if($weFree)
{
// Do the cleanup.
$this->_dependencies = array();
self::$_recursionDetector = NULL;
}
----

Moreover, I discovered one more problem: if the template `c.tpl` does not have `opt:root` instruction, the compiler generates truncated PHP code.

PS. `opt:include` does not check the recursion.

Loading...