projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
oops, losing notes!
[freeside.git]
/
FS
/
FS
/
Record.pm
diff --git
a/FS/FS/Record.pm
b/FS/FS/Record.pm
index
3e7da0d
..
5c8a322
100644
(file)
--- 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
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 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.2
3
;
+use DBIx::DBSchema 0.2
5
;
use FS::UID qw(dbh getotaker datasrc driver_name);
use FS::SearchCache;
use FS::Msgcat qw(gettext);
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]';
$DEBUG = 0;
$me = '[FS::Record]';
+$nowarn_identical = 0;
+
my $conf;
my $rsa_module;
my $rsa_loaded;
my $conf;
my $rsa_module;
my $rsa_loaded;
@@
-883,8
+885,6
@@
sub replace {
my $new = shift;
my $old = shift;
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;
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 "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) );
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
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);
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) ) {
? ($_, $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 '';
}
return '';
}
@@
-1101,7
+1105,9
@@
sub check {
}
sub _h_statement {
}
sub _h_statement {
- my( $self, $action ) = @_;
+ my( $self, $action, $time ) = @_;
+
+ $time ||= time;
my @fields =
grep defined($self->getfield($_)) && $self->getfield($_) ne "",
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 (".
"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).
")"
;
}
")"
;
}