is this a bug or i'm doing something bad?

Author Message

luis muñoz

Tuesday 08 August 2006 8:19:16 am

Hi,

I have the following problem:
If i add this code to one template included from another template:

things....
{set $counter=0}
{do}
{set $counter=inc( $counter )}
many things...
{/do while ne( $counter, $auxactualnode.depth|abs )}

The code works prefectly

But if i include two or more templates from the same template with this code in it breaks. Drops timeout after 180 seconds of 100 mysql load. This happends in 3.7 and 3.8.

But if i replace the do loop with a foreach

things...
{foreach $auxactualnode as $xxx}
many things...
{/foreach}

Then everything works perfectly.

Is this a bug in the do function?

Thanks
Luis

Claudia Kosny

Saturday 12 August 2006 6:04:49 pm

Hi Luis,

it works fine for me (Ez 3.7.5 and 3.8.1).
If you want to go to the root of it I would try some of the following:
Make sure that $counter is defined all the times. Maybe you undef it after including the first template with this code so that during the second call of this loop there is no counter to set and thus the while condition never evaluates to true.

If this is not the problem, try to see what values the counter has in each iteration. To do that print the counter in each iteration and add a conditional {break} within the loop, something like this:

{if is_set($counter)|not}
 {def $counter=0}
{/if}
{set $counter=0}
{do}
 {set $counter=inc( $counter )}
 counter is set to {$counter} <br />
 {if $counter|gt(20)}
   breaking {$counter}
   {break}
 {/if}
{/do while ne( $counter, 10)}

Claudia

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.