Skip to content

Commit

Permalink
Simplify, and fix, _ensureEmail.
Browse files Browse the repository at this point in the history
Fixes duplicating the same email address to multiple
fields in certain cases. Part of Bug: 14301
  • Loading branch information
mrubinsk committed Aug 19, 2016
1 parent efe66d1 commit 43b343d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions turba/lib/Object.php
Expand Up @@ -618,18 +618,12 @@ protected function _ensureEmail()
// email fields, we have no way of knowing where to put them and this
// is better than dropping them.
foreach ($this->_emailFields as $attribute => $email) {
if (empty($this->driver->map[$attribute])) {
if (empty($this->driver->map[$attribute]) && $attribute != 'emails') {
foreach ($this->driver->map as $driver_att => $driver_value) {
if ($attributes[$driver_att]['type'] == 'email' &&
empty($this->attributes[$driver_att])) {
// Hackish way of preventing the 'emails' attribute
// from interfering since it is ALWAYS populated in
// Turba_Driver::toHash()
if (empty($attributes[$driver_att]['allow_multi']) &&
strpos($email, ',') !== false) {
continue;
}
$this->attributes[$driver_att] = $email;
break;
}
}
}
Expand Down

0 comments on commit 43b343d

Please sign in to comment.