X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2FRecord.pm;h=5c8a322c92af34fe9c8bdaee139a07d7efa2666e;hb=e96a3fd1c8ee8c711a7e119c0937da6866bbd4f0;hp=3e7da0dd640b92c1a464ccaf5db5e400ea52adad;hpb=30189fa2e5987bafeb4714a83b7f130c568b221c;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 3e7da0dd6..5c8a322c9 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -2,14 +2,14 @@ package FS::Record; use strict; use vars qw( $dbdef_file $dbdef $setup_hack $AUTOLOAD @ISA @EXPORT_OK $DEBUG - $me %dbdef_cache %virtual_fields_cache ); + $me %dbdef_cache %virtual_fields_cache $nowarn_identical ); use subs qw(reload_dbdef); use Exporter; use Carp qw(carp cluck croak confess); use File::CounterFile; use Locale::Country; use DBI qw(:sql_types); -use DBIx::DBSchema 0.23; +use DBIx::DBSchema 0.25; use FS::UID qw(dbh getotaker datasrc driver_name); use FS::SearchCache; use FS::Msgcat qw(gettext); @@ -25,6 +25,8 @@ use Tie::IxHash; $DEBUG = 0; $me = '[FS::Record]'; +$nowarn_identical = 0; + my $conf; my $rsa_module; my $rsa_loaded; @@ -883,8 +885,6 @@ sub replace { my $new = shift; my $old = shift; - my $saved = {}; - if (!defined($old)) { warn "[debug]$me replace called with no arguments; autoloading old record\n" if $DEBUG; @@ -903,7 +903,9 @@ sub replace { return "Records not in same table!" unless $new->table eq $old->table; my $primary_key = $old->dbdef_table->primary_key; - return "Can't change $primary_key" + return "Can't change primary key $primary_key ". + 'from '. $old->getfield($primary_key). + ' to ' . $new->getfield($primary_key) if $primary_key && ( $old->getfield($primary_key) ne $new->getfield($primary_key) ); @@ -911,6 +913,7 @@ sub replace { return $error if $error; # Encrypt for replace + my $saved = {}; if ($conf->exists('encryption') && defined(eval '@FS::'. $new->table . 'encrypted_fields')) { foreach my $field (eval '@FS::'. $new->table . '::encrypted_fields') { $saved->{$field} = $new->getfield($field); @@ -923,7 +926,8 @@ sub replace { ? ($_, $new->getfield($_)) : () } $old->fields; unless ( keys(%diff) ) { - carp "[warning]$me $new -> replace $old: records identical"; + carp "[warning]$me $new -> replace $old: records identical" + unless $nowarn_identical; return ''; } @@ -1101,7 +1105,9 @@ sub check { } sub _h_statement { - my( $self, $action ) = @_; + my( $self, $action, $time ) = @_; + + $time ||= time; my @fields = grep defined($self->getfield($_)) && $self->getfield($_) ne "", @@ -1112,7 +1118,7 @@ sub _h_statement { "INSERT INTO h_". $self->table. " ( ". join(', ', qw(history_date history_user history_action), @fields ). ") VALUES (". - join(', ', time, dbh->quote(getotaker()), dbh->quote($action), @values). + join(', ', $time, dbh->quote(getotaker()), dbh->quote($action), @values). ")" ; }