Skip to content

Commit

Permalink
Item12616: Registration fields inconsistent
Browse files Browse the repository at this point in the history
Perl 5.18 hash order changes caused each registration email and user
topics to present the form fields in different orders.  Sort the fields
by name so that everything remains consistent.

git-svn-id: http://svn.foswiki.org/branches/Release01x01@17013 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Oct 31, 2013
1 parent 82ae0f7 commit 7cad410
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/lib/Foswiki/UI/Register.pm
Expand Up @@ -1176,7 +1176,8 @@ sub _populateUserTopicForm {
return ( $meta, '' ) unless $form;

foreach my $field ( @{ $form->getFields() } ) {
foreach my $fd ( @{ $data->{form} } ) {
foreach my $fd ( sort { $a->{name} cmp $b->{name} } @{ $data->{form} } )
{
next unless $fd->{name} eq $field->{name};
next if $SKIPKEYS{ $fd->{name} };
my $item = $meta->get( 'FIELD', $fd->{name} );
Expand All @@ -1198,7 +1199,7 @@ sub _populateUserTopicForm {
}
}
my $leftoverText = '';
foreach my $fd ( @{ $data->{form} } ) {
foreach my $fd ( sort { $a->{name} cmp $b->{name} } @{ $data->{form} } ) {
unless ( $inform{ $fd->{name} } || $SKIPKEYS{ $fd->{name} } ) {
$leftoverText .= " * $fd->{name}: $fd->{value}\n";
}
Expand All @@ -1210,7 +1211,7 @@ sub _populateUserTopicForm {
sub _getRegFormAsTopicContent {
my $data = shift;
my $text;
foreach my $fd ( @{ $data->{form} } ) {
foreach my $fd ( sort { $a->{name} cmp $b->{name} } @{ $data->{form} } ) {
next if $SKIPKEYS{ $fd->{name} };
my $title = $fd->{name};
$title =~ s/([a-z0-9])([A-Z0-9])/$1 $2/go; # Spaced
Expand Down Expand Up @@ -1291,7 +1292,7 @@ sub _buildConfirmationEmail {
# like in multi-part mime - txt & html
my ( $before, $after ) = split( /%FORMDATA%/, $templateText );
$before .= $loginName;
foreach my $fd ( @{ $data->{form} } ) {
foreach my $fd ( sort { $a->{name} cmp $b->{name} } @{ $data->{form} } ) {
my $name = $fd->{name};
my $value = $fd->{value};

Expand All @@ -1311,7 +1312,6 @@ sub _buildConfirmationEmail {
$templateText =~ s/( ?) *<\/?(nop|noautolink)\/?>\n?/$1/gois;

# remove <nop> and <noautolink> tags

return $templateText;
}

Expand Down Expand Up @@ -1569,7 +1569,7 @@ sub _validateRegistration {
);
}
my @missing = ();
foreach my $fd ( @{ $data->{form} } ) {
foreach my $fd ( sort { $a->{name} cmp $b->{name} } @{ $data->{form} } ) {
if ( ( $fd->{required} ) && ( !$fd->{value} ) ) {
push( @missing, $fd->{name} );
}
Expand Down

0 comments on commit 7cad410

Please sign in to comment.