Gültigkeit von custom variables nur für Artikelstammdaten speichern
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 17 Jan 2011 16:58:07 +0000 (17:58 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 17 Jan 2011 16:58:07 +0000 (17:58 +0100)
Fix für Bug 1561.

SL/CVar.pm
SL/IC.pm
sql/Pg-upgrade2/invalid_entries_in_custom_variables_validity.sql [new file with mode: 0644]

index 0de9a4b..779bfc3 100644 (file)
@@ -338,10 +338,13 @@ sub save_custom_variables {
 
     do_statement($form, $sth, $query, @values);
 
-    my $valid_index = "$params{name_prefix}cvar_$config->{name}$params{name_postfix}_valid";
-    $self->save_custom_variables_validity(trans_id => $params{trans_id}, config_id => $config->{id},
-      validity => ($params{variables}{$valid_index} || $params{always_valid} ? 1 : 0)
-    );
+    if ($params{save_validity}) {
+      my $valid_index = "$params{name_prefix}cvar_$config->{name}$params{name_postfix}_valid";
+      $self->save_custom_variables_validity(trans_id  => $params{trans_id},
+                                            config_id => $config->{id},
+                                            validity  => ($params{variables}{$valid_index} || $params{always_valid} ? 1 : 0)
+                                           );
+    }
   }
 
   $sth->finish();
index ac3d6f2..b6007d9 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -583,10 +583,11 @@ sub save {
     }
   }
 
-  CVar->save_custom_variables('dbh'       => $dbh,
-                              'module'    => 'IC',
-                              'trans_id'  => $form->{id},
-                              'variables' => $form);
+  CVar->save_custom_variables(dbh           => $dbh,
+                              module        => 'IC',
+                              trans_id      => $form->{id},
+                              variables     => $form,
+                              save_validity => 1);
 
   # commit
   my $rc = $dbh->commit;
diff --git a/sql/Pg-upgrade2/invalid_entries_in_custom_variables_validity.sql b/sql/Pg-upgrade2/invalid_entries_in_custom_variables_validity.sql
new file mode 100644 (file)
index 0000000..62dd944
--- /dev/null
@@ -0,0 +1,9 @@
+-- @tag: invalid_entries_in_custom_variables_validity
+-- @description: Ungültige Einträge in custom_variables_validity bereinigen
+-- @depends: release_2_6_1
+-- @charset: utf-8
+DELETE FROM custom_variables_validity
+WHERE trans_id NOT IN (
+  SELECT id
+  FROM parts
+);