Commit 048c4414 authored by Vincent Pelletier's avatar Vincent Pelletier

ZSQLCatalog: Fix security indexation when indexing the same object multiple times

When an object is being indexed, it get wrapped so it has magic properties,
like security definitions as they will be accessed by indexation methods.
One such property is used to trigger the insertion of rows in
roles_and_users table. That property has the special feature that it is
only produced on the first object needing a new set of rows added to
roles_and_users, other objects will get a None value instead for that
property so that no further lines are inserted.
Then, SQCatalog iterates over that wrapper list to compute all indexation
method parameters. It does so via a cache (LazyIndexationParameterList) so
that unused parameters are not computed. The cache key is wrapped object's
uid.
All this together means that if an object is indexed multiple times in a
single call (which happens at site creation, for example) and it needs a
new set of rows added in roles_and_users, only one of produced wrappers
will get the appropriate value. If that object is not the first on which
that parameter is evaluated (which gets more likely with every copy of the
same object being indexed), it will be cached as None and shared between
all copies, causing no row to be added to roles_and_users.

Full investigation done by by Yusei Tahara.
wrappers will get the
parent 51c065f4
......@@ -728,8 +728,9 @@ class ZCatalog(Folder, Persistent, Implicit):
default_catalog = self.getSQLCatalog()
# Construct list of object to catalogged
object_set = set(object_list)
current_catalog_object_list = []
for obj in object_list:
for obj in object_set:
if hot_reindexing:
try:
url = obj.getPhysicalPath
......@@ -817,10 +818,10 @@ class ZCatalog(Folder, Persistent, Implicit):
if destination_catalog.id != catalog.id:
if self.hot_reindexing_state == HOT_REINDEXING_RECORDING_STATE:
destination_catalog.recordObjectList(url_list, 1)
elif object_list:
elif object_set:
destination_catalog.catalogObjectList(
self.wrapObjectList(
object_value_list=object_list,
object_value_list=object_set,
catalog_value=destination_catalog,
),
**kw
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment