From 7e76e1282d18eeec88be6a777c351ca4116a90cb Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 1 Jul 2013 09:48:31 +0200 Subject: [PATCH] In SL::InstanceConfiguration keine Rose-Objekte nutzen MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Die Klasse muss ihre Daten laden, noch bevor die Datenbankupgrades durch sind. Das bedeutet, dass gerade SL::DB::MetaSetup::Default noch nicht dem Datenbankschema entspricht und das Laden damit fehlschlägt. --- SL/InstanceConfiguration.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/SL/InstanceConfiguration.pm b/SL/InstanceConfiguration.pm index 4e05b841f..31f98c462 100644 --- a/SL/InstanceConfiguration.pm +++ b/SL/InstanceConfiguration.pm @@ -3,8 +3,7 @@ package SL::InstanceConfiguration; use strict; use Carp; -use SL::DB::Currency; -use SL::DB::Default; +use SL::DBUtils (); use parent qw(Rose::Object); use Rose::Object::MakeMethods::Generic ( @@ -12,15 +11,15 @@ use Rose::Object::MakeMethods::Generic ( ); sub init_data { - my $default = SL::DB::Default->get; - my $data = { map { $_ => $default->$_ } $default->meta->columns }; - $data->{default_currency} = $default->currency ? $default->currency->name : undef; + my $dbh = $::form->get_standard_dbh; + my $data = SL::DBUtils::selectfirst_hashref_query($::form, $dbh, qq|SELECT * FROM defaults|); + $data->{default_currency} = (SL::DBUtils::selectfirst_array_query($::form, $dbh, qq|SELECT name FROM currencies WHERE id = ?|, $data->{currency_id}))[0] if $data->{currency_id}; return $data; } sub init_currencies { - return [ map { $_->name } @{ SL::DB::Manager::Currency->get_all_sorted } ]; + return [ map { $_->{name} } SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT name FROM currencies ORDER BY id ASC|) ]; } sub reload { -- 2.20.1