From 483acbc3826790253e45dae4d97be7e9b714027e Mon Sep 17 00:00:00 2001 From: Scott Walters Date: Mon, 31 May 2010 14:39:36 -0400 Subject: [PATCH] Revert "Calls to set() and update() set attributes as well as "properties"." This reverts commit 57fe0721ab6049e02c421cf2b1cb387f4eed42da. --- lib/WebGUI/AssetVersioning.pm | 3 +-- lib/WebGUI/Definition/Role/Object.pm | 23 ++++------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/lib/WebGUI/AssetVersioning.pm b/lib/WebGUI/AssetVersioning.pm index ed2ebf409..eeefe9f3b 100644 --- a/lib/WebGUI/AssetVersioning.pm +++ b/lib/WebGUI/AssetVersioning.pm @@ -126,8 +126,7 @@ sub addRevision { $session->db->commit; # current values, and the user set properties - # my %mergedProperties = (%{$self->get}, %{$properties}, (status => 'pending', revisedBy => $session->user->userId, tagId => $workingTag->getId), ); # XXX results in the setting of read-only properties and nothing else seems to be done with this other than just set them again - my %mergedProperties = ( %{$properties}, status => 'pending', revisedBy => $session->user->userId, tagId => $workingTag->getId, ); + my %mergedProperties = (%{$self->get}, %{$properties}, (status => 'pending', revisedBy => $session->user->userId, tagId => $workingTag->getId), ); #Instantiate new revision and fill with real data my $newVersion = WebGUI::Asset->newById($session, $self->getId, $now); diff --git a/lib/WebGUI/Definition/Role/Object.pm b/lib/WebGUI/Definition/Role/Object.pm index e00358d4d..4c1c74a79 100644 --- a/lib/WebGUI/Definition/Role/Object.pm +++ b/lib/WebGUI/Definition/Role/Object.pm @@ -85,23 +85,13 @@ is not an attribute of the object, then it is silently ignored. =cut sub set { - my $self = shift; my $properties = @_ % 2 ? shift : { @_ }; - my %seen; - - my @settable = grep { ! $seen{$_}++ } ( - $self->getProperties, # $self->meta->get_all_property_list, # same as $self->getProperties - $self->getReadableAttributes, - ); - - for my $attribute ( @settable ) { - next unless exists $properties->{$attribute}; - $self->$attribute( $properties->{$attribute} ); + my @orderedProperties = $self->getProperties; + KEY: for my $property ( @orderedProperties ) { + next KEY unless exists $properties->{$property}; + $self->$property($properties->{$property}); } - - # ignore unknown properties - return 1; } @@ -191,10 +181,5 @@ sub getProperties { return $self->meta->get_all_property_list; } -sub getReadableAttributes { - my $self = shift; - return map $_->name, grep $_->has_accessor || $_->has_writer, $self->meta->get_all_attributes; -} - 1;