template::set_file unexpected behaviour
Brought to you by:
nhruby,
richardarcher
Reported via email by Joe Stewart:
If you call set_file twice with the same handle name
but different
filenames, the second file doesn't get loaded because
loadfile checks for
the existence of the varval and returns without loading
the file.
I was able to work around it by unsetting the varval
and varkey of the
handle before calling set_file. But it seems set_file
should do this if
$this->file[$varname] != $filename.
Logged In: YES
user_id=279311
I imagine that in typical use set_file would only be called
once per varname, and anything else would be unintended.
Nevertheless, I can see that if you *do* want to override a
previous file, the current system makes this inordinately
difficult.
How should this change?
- leave as is with better documentation?
- blindly overrwrite the filename?
- throw an error if the same handle is set_file'd twice?
- ...
...R.
Logged In: YES
user_id=77269
A little clarification:
Regarding - blindly overrwrite the filename?
That is not what I suggested. I only suggested that the
contents of the file requested to be used in the call to
set_file be used.
The call to set_file does change the file to be used
successfully now. It's just that loadfile checks for the
variable and if it exists does not grab the contents of the
new file and instead uses the current content ( old file).
The behavior of loadfile is otherwise a good thing and don't
suggest changing it.
thanks,
Joe
Logged In: YES
user_id=77269
Patch available here: [ 606946 ] template::set_file
unexpected behaviour -
https://sourceforge.net/tracker/index.php?func=detail&aid=606946&group_id=31885&atid=403613