[Erp5-report] r25759 - /erp5/trunk/products/ZSQLCatalog/SQLCatalog.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Mar 2 07:05:05 CET 2009


Author: yo
Date: Mon Mar  2 07:05:04 2009
New Revision: 25759

URL: http://svn.erp5.org?rev=25759&view=rev
Log:
uid duplications were not checked inside object_list passed to catalogObjectList, so if two or more objects had the same uid, and they are passed to catalogObjectList at a time, an integrity error was returned from MySQL.

Modified:
    erp5/trunk/products/ZSQLCatalog/SQLCatalog.py

Modified: erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SQLCatalog.py?rev=25759&r1=25758&r2=25759&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] (original)
+++ erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] Mon Mar  2 07:05:04 2009
@@ -1314,6 +1314,11 @@
       path_uid_dict = self.getUidDictForPathList(path_list=path_list)
       uid_path_dict = self.getPathDictForUidList(uid_list=uid_list)
 
+    # This dict will store uids and objects which are verified below.
+    # The purpose is to prevent multiple objects from having the same
+    # uid inside object_list.
+    assigned_uid_dict = {}
+
     for object in object_list:
       if not getattr(aq_base(object), 'uid', None):
         try:
@@ -1324,6 +1329,12 @@
           raise RuntimeError, 'could not set missing uid for %r' % (object,)
       elif check_uid:
         uid = object.uid
+        if uid in assigned_uid_dict:
+          object.uid = self.newUid()
+          LOG('SQLCatalog', WARNING,
+              'uid of %r changed from %r to %r as old one is assigned to %r !!! This can be fatal. You should reindex the whole site immediately.' % (object, uid, object.uid, assigned_uid_dict[uid]))
+          uid = object.uid
+
         path = object.getPath()
         index = path_uid_dict.get(path, None)
         try:
@@ -1377,6 +1388,9 @@
             object.uid = self.newUid()
             LOG('SQLCatalog', WARNING,
                 'uid of %r changed from %r to %r as old one is assigned to %s in catalog !!! This can be fatal. You should reindex the whole site immediately.' % (object, uid, object.uid, catalog_path))
+            uid = object.uid
+
+        assigned_uid_dict[uid] = object
 
     if method_id_list is None:
       method_id_list = self.sql_catalog_object_list




More information about the Erp5-report mailing list