Ticket #12769 (closed Bug: duplicate)

Opened 2 years ago

Last modified 20 months ago

PropertyValueError while setMemberProperties without checking the property's type

Reported by: mekell Owned by:
Priority: minor Milestone: 3.x
Component: Backend (Python) Version:
Keywords: PAS Cc:

Description

When "setMemberProperties" of "MemberData" tries to set the properties, it sets the given property on ALL user's sheets providing IMutablePropertySheet.

There are some situations, where a user has more than one propertysheet with the same propertyId BUT with different types. IMHO those should be therefore considered as two different properties.

An example of such a situation is FacultyStaffDirectory. Here the user has two propertysheets: membrane_properties, and mutable_properties. Both propertysheets have a property with the same id='ext_editor' but of different types (boolean in mutable_properties, string in membrane_properties) When the property "ext_editor" is set via "Personal Preferences" (i.e. /Plone/personalize_form) it succeeds on "mutable_properties" but fails on "membrane_properties" because the value is of type boolean.

Because setMemberProperties do not check the type of the property it fails on setting the boolean value in "ext_editor:string". Actually checking the property is delegated to validateProperty, which unfortunately simply raises an exception.

To solve such situations, one could check the type before setting the property and only setting it in such propertysheets matching the id AND the type of the property.

A simple workaround could be as follows


on Products.PlonePAS-4.0.11-py2.6.egg/Products/PlonePAS/tools/memberdata.py

@@ -272,8 +272,12 @@

if not sheet.hasProperty(k):

continue

if IMutablePropertySheet.providedBy(sheet):

  • sheet.setProperty(user, k, v)
  • modified = True

+ try: + sheet.validateProperty(k, v) + sheet.setProperty(user, k, v) + modified = True + except PropertyValueError: + pass

else:

break #raise RuntimeError, ("Mutable property provider "


Change History

comment:1 Changed 2 years ago by eleddy

  • Status changed from new to confirmed
  • Keywords PAS added; PlonePASmemberdatasetMemberProperties removed
  • Version 4.1 deleted
  • Component changed from Unknown to Backend (Python)

IS this still the case in plone 4?

comment:2 Changed 2 years ago by mekell

test

comment:3 Changed 20 months ago by eleddy

Can you please confirm this for plone 4 or close out? also, this is a VERY specific bug - perhaps a github pull request would go farther than this?

comment:4 Changed 20 months ago by mekell

  • Status changed from confirmed to closed
  • Resolution set to duplicate

When I created this ticket, Trac permissions did not allow to modify it.

After this, I created #12771 (ticket regarding trac permissions). In it I asked to add the patch to a new ticket #12778 (on comment 6 of #12771). This comment was overseen. Ticket #12778 was correctly marked as duplicated of #12769.

I've created a new ticket #13119 (which is still open!).

I close his ticket since it is a duplicate of #13119

Note: See TracTickets for help on using tickets.