[PATCH conductor] fixed bug in session_entites migration that was hit when there was invalid db data

Scott Seago sseago at redhat.com
Fri Jun 8 15:39:13 UTC 2012


If a user attempts to log in with the session_entities fix but
prior to running the migration, an invalid session_entity is
created (with '0' session_id), and then the migration would
fail due to improper handling of exceptions.
---
 ...06200000_fix_session_id_for_session_entities.rb |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/db/migrate/20120606200000_fix_session_id_for_session_entities.rb b/src/db/migrate/20120606200000_fix_session_id_for_session_entities.rb
index 908edae..5d8a22a 100644
--- a/src/db/migrate/20120606200000_fix_session_id_for_session_entities.rb
+++ b/src/db/migrate/20120606200000_fix_session_id_for_session_entities.rb
@@ -19,12 +19,12 @@ class FixSessionIdForSessionEntities < ActiveRecord::Migration
     add_column :session_entities, :session_id, :string
     SessionEntity.reset_column_information
     SessionEntity.all.each do |se|
-      session = ActiveRecord::SessionStore::Session.find(se.session_db_id)
-      if session
+      begin
+        session = ActiveRecord::SessionStore::Session.find(se.session_db_id)
         se.session_id = session.session_id
         se.save!
-      else
-        se.delete!
+      rescue
+        se.destroy
       end
     end
     remove_column :session_entities, :session_db_id
@@ -40,7 +40,7 @@ class FixSessionIdForSessionEntities < ActiveRecord::Migration
         se.session_db_id = session.id
         se.save!
       else
-        se.delete!
+        se.destroy
       end
     end
     remove_column :session_entities, :session_id
-- 
1.7.6.5




More information about the aeolus-devel mailing list