[pLog-svn] r3198 - plog/trunk

Oscar Renalias oscar at renalias.net
Thu Apr 6 21:32:28 GMT 2006


You are right. The problem here, I believe, is that by doing this

  foreach( $checkGroups as $checks ) {

PHP was creating a copy of each array in the $checkGroups array and
storing it in $checks, as opposed to using a  reference. What was
happening is that later on, we were passing $checkGroups to the
template instead of $checks and since we had been working on a copy of
each one of the subarrays, the objects in $checkGroup had been
initialized correctly but the validate() had not been run therefore
isValid() was returning a negative result.

What I just did is that we are now working on the original array
$checkGroups by using indexes to access it... I really didn't know it
worked like this, so we had to find out the hard way.

Oscar

On 4/6/06, Jon Daley <plogworld at jon.limedaley.com> wrote:
>         I don't understand why this change was needed.  The $checks object
> is a separate object than the $checkGroups, so if you modify $checks,
> $checkGroups isn't changed?
>         If that is the case, I want to keep that in my head, because that
> looks like an easy way for me to screw up something.
>
>
> On Thu, 6 Apr 2006, oscar at devel.lifetype.net wrote:
> >
> > this was a tricky one... All checks were being unsuccessful in the
> > wizard template because the objects that was being passed in the array
> > were not the same objects that were being instantiated and executed.
> >
> > Modified: plog/trunk/wizard.php
> > ===================================================================
> > --- plog/trunk/wizard.php     2006-04-06 11:49:20 UTC (rev 3197)
> > +++ plog/trunk/wizard.php     2006-04-06 20:26:24 UTC (rev 3198)
> > -            foreach( $checkGroups as $checks ) {
> > +            foreach( $checkGroups as $checkGroup => $checks ) {
> >                   foreach( $checks as $id => $check ) {
> > -                     $valid = $checks["$id"]->validate();
> > +                     $valid = $checkGroups[$checkGroup][$id]->validate();
> >                       // if it doesn't validate but it's not critical, then we can proced too
> > -                     if( !$checks["$id"]->isCritical())
> > -                         $valid = true;
> > +                     if( !$checkGroups[$checkGroup][$id]->isCritical())
> > +                         $valid = true;
> >                       $ok = ($ok && $valid);
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn
>


More information about the pLog-svn mailing list