Update 2004-06-13: The commit from yesterday contained an error which caused nested ifs not to work correctly. Now fixed.
Today, I committed a small improvement to the PARSER.php class into CVS. It greatly improves performance on sites with complex if-else structures.
Here's what happened in the past when an <%if> was encountered:The condition was evaluated and added to a stack, after which output buffering was started. When an else / endif skinvar was encountered, the buffer was either dumped to the output (if the condition was true), or discarded (if the condition was false).
The problem with this approach is that skinvars in an undisplayed if section are still executed. Consider the following example:
<%if(...)%>
<%blog(template1,15)%>
<%endif%>
<%if(...)%>
<%blog(template2,15)%>
<%endif%>
<%if(...)%>
<%blog(template3,15)%>
<%endif%>
In this case, each of the blog skinvars would cause the database to be queried for blog items and templates, and the templates would be applied to those blog items.
The solution is rather simple:
- At each time, have a variable telling if the data will be seen by the client or not: either
1or0is stored in theif_currentlevelvariable, defined and managed in theBaseActionsclass. - While parsing, ignore all actions except
if,elseandendifwhenif_currentlevelis0
The data in between skinvars is still sent to the buffered output, which is discarded afterwards. But I don't think this is a big problem.

Comments
Add Comment