def / undef Bug

Author Message

Marko Žmak

Friday 25 November 2005 6:34:08 am

I encountered this "bug" with the undef operator. When I "undef" a variable previously declared with "def" i get a "undefined variable" error. Here is the scenario...

I have "template1.tpl" like this:

{def $myvar=1}
{include uri='design:template2.tpl}
My variable in template1: {$myvar}

and "template2.tpl" like this:

My variable in template2: {$myvar}
{undef $myvar}

The output of this code is like this:

My variable in template2: 1
My variable in template1: 

That's OK, since undef destroyed $myvar variable, but in the debug I get the following error:

Undefined Variable: $:myvar, cannot unset

I think that this error shouldn't happen because $myvar i defined, and also undef actually destroys it, so it's confusing, especially when you use it often.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Marko Žmak

Monday 28 November 2005 2:32:55 pm

Could someone take a look at this "bug":

http://ez.no/community/bugs/def_undef_bug

I understand the answer why the bug is closed, but why then the variable IS UNDEFINED when "undef" is called from the other template?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

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

eZ debug

Timing: Jan 20 2025 06:42:59
Script start
Timing: Jan 20 2025 06:42:59
Module start 'layout'
Timing: Jan 20 2025 06:42:59
Module start 'content'
Timing: Jan 20 2025 06:42:59
Module end 'content'
Timing: Jan 20 2025 06:42:59
Script end

Main resources:

Total runtime0.0136 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 589.0313152.6094
Module start 'layout' 0.00520.0025 741.640639.4141
Module start 'content' 0.00770.0040 781.054789.3203
Module end 'content' 0.01170.0019 870.375030.3047
Script end 0.0136  900.6797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002417.7676140.0002
Check MTime0.00128.5078140.0001
Mysql Total
Database connection0.00075.411810.0007
Mysqli_queries0.002216.412530.0007
Looping result0.00000.087710.0000
Template Total0.001611.510.0016
Template load0.00085.964010.0008
Template processing0.00075.462610.0007
Override
Cache load0.00064.212710.0006
General
dbfile0.00031.996880.0000
String conversion0.00000.045640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs