BUGFIX Unsetting 'ID' parameter in MemberTableField->addtogroup() to avoid confusion between Group and Member records (regression from r100716) (from r100720)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@100721 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-03-09 20:30:34 +00:00 committed by Sam Minnee
parent 9466e07335
commit abe4049c3d

View File

@ -170,9 +170,7 @@ class MemberTableField extends ComplexTableField {
$identifierField = Member::get_unique_identifier_field(); $identifierField = Member::get_unique_identifier_field();
$className = self::$data_class; $className = self::$data_class;
$record = null; $record = null;
if(isset($data['ID']) && $data['ID']) { if(isset($data[$identifierField])) {
$record = DataObject::get_by_id($className, $data['ID']);
} elseif(isset($data[$identifierField])) {
$record = DataObject::get_one( $record = DataObject::get_one(
$className, $className,
sprintf('"%s" = \'%s\'', $identifierField, $data[$identifierField]) sprintf('"%s" = \'%s\'', $identifierField, $data[$identifierField])
@ -184,7 +182,10 @@ class MemberTableField extends ComplexTableField {
// Update an existing record, or populate a new one. // Update an existing record, or populate a new one.
// If values on an existing (autocompleted) record have been changed, // If values on an existing (autocompleted) record have been changed,
// they will overwrite current data. // they will overwrite current data. We need to unset 'ID'
// record as it points to the group rather than the member record, and would
// cause the member to be written to a potentially existing record.
unset($data['ID']);
$record->update($data); $record->update($data);
// Validate record, mainly password restrictions. // Validate record, mainly password restrictions.