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

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@100720 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-03-09 20:28:59 +00:00
parent 4eed1360c4
commit 129ab60ae7

View File

@ -171,9 +171,7 @@ class MemberTableField extends ComplexTableField {
$identifierField = Member::get_unique_identifier_field();
$className = self::$data_class;
$record = null;
if(isset($data['ID']) && $data['ID']) {
$record = DataObject::get_by_id($className, $data['ID']);
} elseif(isset($data[$identifierField])) {
if(isset($data[$identifierField])) {
$record = DataObject::get_one(
$className,
sprintf('"%s" = \'%s\'', $identifierField, $data[$identifierField])
@ -185,7 +183,10 @@ class MemberTableField extends ComplexTableField {
// Update an existing record, or populate a new one.
// 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);
// Validate record, mainly password restrictions.