Defect #33926

Rake tasks "db:encrypt" and "db:decrypt" may fail due to validation error

Added by Go MAEDA about 1 month ago. Updated about 1 month ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Accounts / authentication
Target version:4.0.8
Resolution:Fixed Affected version:

Description

encrypt_all and decrypt_all methods in lib/redmine/ciphering.rb are expected to skip validation when saving an object. But they don't because of typo in parameter name.

It may cause a failure to run rake db:encrypt or rake db:decrypt. You can reproduce it by running the following commands.

$ bin/rake db:fixtures:load
$ bin/rake db:encrypt
rake aborted!
Some objects could not be saved after encryption, update was rolled back.

Here is a fix:

diff --git a/lib/redmine/ciphering.rb b/lib/redmine/ciphering.rb
index d5ceb0c6c..469d3b9e6 100644
--- a/lib/redmine/ciphering.rb
+++ b/lib/redmine/ciphering.rb
@@ -74,7 +74,7 @@ module Redmine
           all.each do |object|
             clear = object.send(attribute)
             object.send "#{attribute}=", clear
-            raise(ActiveRecord::Rollback) unless object.save(:validation => false)
+            raise(ActiveRecord::Rollback) unless object.save(validate: false)
           end
         end ? true : false
       end
@@ -84,7 +84,7 @@ module Redmine
           all.each do |object|
             clear = object.send(attribute)
             object.send :write_attribute, attribute, clear
-            raise(ActiveRecord::Rollback) unless object.save(:validation => false)
+            raise(ActiveRecord::Rollback) unless object.save(validate: false)
           end
         end ? true : false
       end

33926.patch Magnifier (1.86 KB) Go MAEDA, 2020-08-30 15:02

Associated revisions

Revision 19999
Added by Go MAEDA about 1 month ago

Rake tasks "db:encrypt" and "db:decrypt" may fail due to validation error (#33926).

Patch by Go MAEDA.

Revision 20003
Added by Go MAEDA about 1 month ago

Merged r19999 from trunk to 4.1-stable (#33926).

Revision 20004
Added by Go MAEDA about 1 month ago

Merged r19999 from trunk to 4.0-stable (#33926).

History

#1 Updated by Go MAEDA about 1 month ago

  • Subject changed from Validation is not skipped due to typo when running db:encrypt/db:decrypt rake tasks to "rake db:encrypt" / "rake db:decrypt" may fail due to validation error

#2 Updated by Go MAEDA about 1 month ago

Added test code.

#3 Updated by Go MAEDA about 1 month ago

  • Target version set to 4.0.8

Setting the target version to 4.0.8.

#4 Updated by Go MAEDA about 1 month ago

  • Status changed from New to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch.

#5 Updated by Go MAEDA about 1 month ago

  • Subject changed from "rake db:encrypt" / "rake db:decrypt" may fail due to validation error to Rake tasks "db:encrypt" and "db:decrypt" may fail due to validation error

#6 Updated by Go MAEDA about 1 month ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF