Skip to content

Commit

Permalink
BUGFIX Unsetting 'ID' parameter in MemberTableField->addtogroup() to …
Browse files Browse the repository at this point in the history
…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
chillu committed Mar 9, 2010
1 parent 4eed136 commit 129ab60
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions code/MemberTableField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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.
Expand Down

0 comments on commit 129ab60

Please sign in to comment.