[MTOS-dev] [movabletype] bchoate, r1859: Applied patches for if/elseif stomping o...

Hirotaka Ogawa hirotaka.ogawa at gmail.com
Thu Apr 10 23:34:32 PDT 2008


On Fri, Apr 11, 2008 at 3:02 PM,  <commits at code.sixapart.com> wrote:
> Applied patches for if/elseif stomping on __value__ variable. BugId:79027 Thanks, Ogawa-san.
>
>
>  U   branches/release-34/lib/MT/Builder.pm
>  U   branches/release-34/lib/MT/Template/ContextHandlers.pm
>
>
>  Modified: branches/release-34/lib/MT/Builder.pm
>  ===================================================================
>  --- branches/release-34/lib/MT/Builder.pm       2008-04-11 04:56:39 UTC (rev 1858)
>  +++ branches/release-34/lib/MT/Builder.pm       2008-04-11 06:01:58 UTC (rev 1859)
>  @@ -397,9 +397,10 @@
>
>                  if ((defined $type) && ($type == 2)) {
>                      # conditional; process result
>  +                    my $vars = $ctx->{__stash}{vars};
>  +                    local $vars->{__value__} = delete $vars->{__cond_value__};
>  +                    local $vars->{__name__}  = delete $vars->{__cond_name__};
>                      $out = $out ? $ctx->slurp(\%args, $cond) : $ctx->else(\%args, $cond);
>  -                    delete $ctx->{__stash}{vars}{__value__};
>  -                    delete $ctx->{__stash}{vars}{__name__};
>                      return $build->error(MT->translate("Error in <mt[_1]> tag: [_2]", $t->[0], $ctx->errstr))
>                          unless defined $out;
>                  }
>
>  Modified: branches/release-34/lib/MT/Template/ContextHandlers.pm
>  ===================================================================
>  --- branches/release-34/lib/MT/Template/ContextHandlers.pm      2008-04-11 04:56:39 UTC (rev 1858)
>  +++ branches/release-34/lib/MT/Template/ContextHandlers.pm      2008-04-11 06:01:58 UTC (rev 1859)
>  @@ -1417,8 +1417,8 @@
>          }
>      }
>
>  -    $ctx->{__stash}{vars}->{__value__} = $value;
>  -    $ctx->{__stash}{vars}->{__name__} = $var;
>  +    local $ctx->{__stash}{vars}{__cond_value__} = $value;
>  +    local $ctx->{__stash}{vars}{__cond_name__} = $var;

These should not be 'local'.  Because, they'll be undefined after
finishing _hdlr_if() method.

Basically, this part works like:

(1) _hdlr_if() sets __cond_value__ and __cond_name__.
(2) MT::Builder->build() gets __cond_value__ and __cond_name__ and
stores them to __value__ and __name__ in the local scope.
(3) excute a certain conditional handler with using this context.
(4) after finishing MT::Builder->build(), __value__ and __name__ are
set to original values.

>
>      if ( my $op = $args->{op} ) {
>          my $rvalue = $args->{'value'};
>
>
>  _______________________________________________
>  MTOS-commits mailing list
>  MTOS-commits at sixapart.com
>  http://www.sixapart.com/mailman/listinfo/mtos-commits
>



-- 
Hirotaka Ogawa
http://twitter.com/ogawa
http://as-is.net/blog/


More information about the MTOS-dev mailing list