Bug 6554 Fix error caused by modifying $_ in a map
authorColin Campbell <colin.campbell@ptfs-europe.com>
Thu, 4 Apr 2013 09:54:03 +0000 (10:54 +0100)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Thu, 18 Apr 2013 13:26:22 +0000 (09:26 -0400)
Error 'Modification of a read-only value attempted' triggered
on login because of manipulation of $_ in the map

Moved the mod to a loop as recommended in the doc for map

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
C4/Context.pm

index 4d170b2..fee8752 100644 (file)
@@ -1104,9 +1104,22 @@ set_userenv is called in Auth.pm
 
 #'
 sub set_userenv {
-    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $persona)=
-    map { utf8::decode($_); $_ } # CGI::Session doesn't handle utf-8, so we decode it here
-    @_;
+    my (
+        $usernum,      $userid,        $usercnum,   $userfirstname,
+        $usersurname,  $userbranch,    $branchname, $userflags,
+        $emailaddress, $branchprinter, $persona
+    ) = @_;
+    for (
+        $usernum,      $userid,        $usercnum,   $userfirstname,
+        $usersurname,  $userbranch,    $branchname, $userflags,
+        $emailaddress, $branchprinter, $persona
+      )
+    {
+        utf8::decode($_) if $_;
+    }
+
+    # CGI::Session doesn't handle utf-8, so we decode it here
+
     my $var=$context->{"activeuser"} || '';
     my $cell = {
         "number"     => $usernum,