nuked each() out of core with prejudice
Matt S Trout [Mon, 22 May 2006 02:30:34 +0000 (02:30 +0000)]
Changes
lib/Catalyst.pm
lib/Catalyst/Engine.pm
lib/Catalyst/Engine/CGI.pm
lib/Catalyst/Engine/HTTP.pm

diff --git a/Changes b/Changes
index b786981..272c571 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
 This file documents the revision history for Perl extension Catalyst.
 
+        - nuked each() out of core with prejudice (due to lurking buglets)
+        - Added tests from phaylon for dispatcher precedence
         - Use Class::Inspector->loaded($class) instead of $class->can('can')
         - Added ActionClass attribute
         - Removed Test::WWW::Mechanize::Catalyst from Makefile.PL (circular dep)
index c206761..99a8767 100644 (file)
@@ -324,8 +324,8 @@ sub stash {
     if (@_) {
         my $stash = @_ > 1 ? {@_} : $_[0];
        croak('stash takes a hash or hashref') unless ref $stash;
-        while ( my ( $key, $val ) = each %$stash ) {
-            $c->{stash}->{$key} = $val;
+        foreach my $key ( keys %$stash ) {
+            $c->{stash}->{$key} = $stash->{$key};
         }
     }
     return $c->{stash};
index de506cb..6e46c81 100644 (file)
@@ -62,15 +62,18 @@ sub finalize_cookies {
     my ( $self, $c ) = @_;
 
     my @cookies;
-    while ( my ( $name, $cookie ) = each %{ $c->response->cookies } ) {
+
+    foreach my $name ( keys %{ $c->response->cookies } ) {
+
+        my $val = $c->response->cookies->{$name};
 
         my $cookie = CGI::Cookie->new(
             -name    => $name,
-            -value   => $cookie->{value},
-            -expires => $cookie->{expires},
-            -domain  => $cookie->{domain},
-            -path    => $cookie->{path},
-            -secure  => $cookie->{secure} || 0
+            -value   => $val->{value},
+            -expires => $val->{expires},
+            -domain  => $val->{domain},
+            -path    => $val->{path},
+            -secure  => $val->{secure} || 0
         );
 
         push @cookies, $cookie->as_string;
@@ -388,13 +391,15 @@ sub prepare_parameters {
     my ( $self, $c ) = @_;
 
     # We copy, no references
-    while ( my ( $name, $param ) = each %{ $c->request->query_parameters } ) {
+    foreach my $name ( keys %{ $c->request->query_parameters } ) {
+        my $param = $c->request->query_parameters->{$name};
         $param = ref $param eq 'ARRAY' ? [ @{$param} ] : $param;
         $c->request->parameters->{$name} = $param;
     }
 
     # Merge query and body parameters
-    while ( my ( $name, $param ) = each %{ $c->request->body_parameters } ) {
+    foreach my $name ( keys %{ $c->request->body_parameters } ) {
+        my $param = $c->request->body_parameters->{$name};
         $param = ref $param eq 'ARRAY' ? [ @{$param} ] : $param;
         if ( my $old_param = $c->request->parameters->{$name} ) {
             if ( ref $old_param eq 'ARRAY' ) {
index fae6a9a..17e4eed 100644 (file)
@@ -94,10 +94,10 @@ sub prepare_headers {
     local (*ENV) = $self->env || \%ENV;
 
     # Read headers from %ENV
-    while ( my ( $header, $value ) = each %ENV ) {
+    foreach my $header ( keys %ENV ) {
         next unless $header =~ /^(?:HTTP|CONTENT|COOKIE)/i;
         ( my $field = $header ) =~ s/^HTTPS?_//;
-        $c->req->headers->header( $field => $value );
+        $c->req->headers->header( $field => $ENV{$header} );
     }
 }
 
index 0024009..60a166d 100644 (file)
@@ -178,8 +178,10 @@ sub run {
             my $sockdata = $self->_socket_data( \*Remote );
             my $ipaddr   = _inet_addr( $sockdata->{peeraddr} );
             my $ready    = 0;
-            while ( my ( $ip, $mask ) = each %$allowed and not $ready ) {
+            foreach my $ip ( keys %$allowed ) {
+                my $mask = $allowed->{$ip};
                 $ready = ( $ipaddr & _inet_addr($mask) ) == _inet_addr($ip);
+                last if $ready;
             }
             if ($ready) {
                 $restart = 1;