Permalink
Browse files

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
  • Loading branch information...
1 parent 4eed136 commit 129ab60ae777249b210c53738d8045822adc3e79 @chillu chillu committed Mar 9, 2010
Showing with 5 additions and 4 deletions.
  1. +5 −4 code/MemberTableField.php
View
9 code/MemberTableField.php
@@ -171,9 +171,7 @@ function addtogroup() {
$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 @@ function addtogroup() {
// 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.

0 comments on commit 129ab60

Please sign in to comment.