Based on my understanding of PHP it seems that __isset() is returning 
correctly. At that point in time exampleVariable is not set. Can it be set in 
the future? Sure, but it's not currently.

-- 
#Terin Stock
Undergraduate, Computer Science (CISE), University of Florida

On Monday, June 27, 2011 at 12:52 AM, Marco Pivetta wrote:

> Maybe it's just me, but when I have some lazily loaded data I build __isset() 
> accordingly, otherwise __isset() itself is inconsistent...
> 
> Marco Pivetta
> http://twitter.com/Ocramius
> http://marco-pivetta.com
> 
> 
> 
> On 27 June 2011 08:25, Terin Stock <terinjo...@gmail.com 
> (mailto:terinjo...@gmail.com)> wrote:
> > Normally I can understand that being a stumbling block.
> > 
> > The issue here is that my objects lazy-load a sizable amount of the 
> > instance variables, thus the use of __get() to retrieve (or generate) any 
> > that haven't already been set. A few of them are accessed in my controller, 
> > but others are only accessed in the view. Thus, when the view executes, any 
> > instance variables that haven't been fetched yet are still NULL, causing 
> > isset() to return FALSE. 
> > 
> > -- 
> > 
> > #Terin Stock
> > Undergraduate, Computer Science (CISE), University of Florida
> > 
> > On Sunday, June 26, 2011 at 8:01 PM, Tjerk Meesters wrote:
> > 
> > > On Mon, Jun 27, 2011 at 6:36 AM, Terin Stock <terinjo...@gmail.com 
> > > (mailto:terinjo...@gmail.com)> wrote:
> > > > I've been working with PHPTAL for quite some time, and have always been
> > > >  annoyed that from within the template an object's __get method was 
> > > > being
> > > > ignored. I think I've tracked down the bug (in version 1.2.2, though it
> > > > still present in trunk).
> > > > The scenario: an object, exampleObject, implements __isset, but returns
> > > >  false (exampleVariable is not set). exampleObject also implements 
> > > > __get, and
> > > > returns something that isn't NULL.
> > > > As __isset is implemented, the if condition on line 378 is satisfied, 
> > > > but
> > > > because exampleVariable is not set, the if condition on line 379 is not 
> > > > met,
> > > >  and the loop does not continue.
> > > 
> > > Out of curiosity, why would it make sense to read a variable's content
> > > when isset() returns false?
> > > 
> > > > 
> > > > However, since the if condition on line 385 (checking to see if __get is
> > > >  implemented) is an elseif, it is skipped–the condition on line 378
> > > > passed–right to the if condition on line 394 (the one checking to see if
> > > > __call is implemented). As exampleVariable isn't a method, it to fails, 
> > > > and
> > > >  the PHPTAL_Context:pathError method is executed.
> > > > My patch is simple, changing one line. Everything seems to work as 
> > > > expected
> > > > with the change, though I'm happy to hear any problems you have with it.
> > > > diff --git a/PHPTAL/Context.php b/PHPTAL/Context.php
> > > >  --- a/PHPTAL/Context.php
> > > > +++ b/PHPTAL/Context.php
> > > > @@ -382,7 +382,7 @@ class PHPTAL_Context
> > > >  }
> > > >  }
> > > >  // ask __get and discard if it returns null
> > > > - elseif (method_exists($base, '__get')) {
> > > >  + if (method_exists($base, '__get')) {
> > > >  $tmp = $base->$current;
> > > >  if (null !== $tmp) {
> > > >  $base = $tmp;
> > > > --
> > > > #Terin Stock
> > > >  Undergraduate, Computer Science (CISE), University of Florida
> > > > 
> > > > _______________________________________________
> > > > PHPTAL mailing list
> > > > PHPTAL@lists.motion-twin.com (mailto:PHPTAL@lists.motion-twin.com)
> > > > http://lists.motion-twin.com/mailman/listinfo/phptal
> > > 
> > > 
> > > 
> > > -- 
> > > --
> > > Tjerk
> > > 
> > > _______________________________________________
> > >  PHPTAL mailing list
> > > PHPTAL@lists.motion-twin.com (mailto:PHPTAL@lists.motion-twin.com)
> > > http://lists.motion-twin.com/mailman/listinfo/phptal
> > 
> > 
> > _______________________________________________
> >  PHPTAL mailing list
> > PHPTAL@lists.motion-twin.com (mailto:PHPTAL@lists.motion-twin.com)
> > http://lists.motion-twin.com/mailman/listinfo/phptal
> > 
> 
> _______________________________________________
> PHPTAL mailing list
> PHPTAL@lists.motion-twin.com (mailto:PHPTAL@lists.motion-twin.com)
> http://lists.motion-twin.com/mailman/listinfo/phptal

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to