Commit bb225de3 authored by Côme Bernigaud's avatar Côme Bernigaud Committed by Benoit Mortier
Browse files

Fixes: #2589 foreignKeys handled in deletion case

Showing with 13 additions and 7 deletions
+13 -7
...@@ -864,16 +864,15 @@ class simplePlugin extends plugin ...@@ -864,16 +864,15 @@ class simplePlugin extends plugin
$infos = pluglist::pluginInfos(get_class($this)); $infos = pluglist::pluginInfos(get_class($this));
$foreignRefs = array(); $foreignRefs = array();
foreach ($infos['plForeignRefs'] as $field => $refs) { foreach ($infos['plForeignRefs'] as $field => $refs) {
if ($olddn !== NULL) { if ($newdn !== NULL) {
if ($field != 'dn') { if ($field != 'dn') {
continue; continue;
} }
} else { } else {
if ($field == 'dn') { if ($field != 'dn') {
continue; if (!$this->attributesAccess[$field]->hasChanged()) {
} continue;
if (!$this->attributesAccess[$field]->hasChanged()) { }
continue;
} }
} }
foreach ($refs as $ref) { foreach ($refs as $ref) {
...@@ -901,13 +900,20 @@ class simplePlugin extends plugin ...@@ -901,13 +900,20 @@ class simplePlugin extends plugin
// For each field // For each field
foreach ($fieldRefs as $ofield => $field) { foreach ($fieldRefs as $ofield => $field) {
// call plugin::foreignKeyUpdate(ldapname, oldvalue, newvalue) on the object // call plugin::foreignKeyUpdate(ldapname, oldvalue, newvalue) on the object
if ($olddn !== NULL) { if ($field == 'dn') {
$tabobject->by_object[$tab]->foreignKeyUpdate( $tabobject->by_object[$tab]->foreignKeyUpdate(
$ofield, $ofield,
$olddn, $olddn,
$newdn, $newdn,
$field $field
); );
} elseif (($olddn !== NULL) && ($newdn === NULL)) {
$tabobject->by_object[$tab]->foreignKeyUpdate(
$ofield,
$this->attributesAccess[$field]->getInitialValue(),
NULL,
$field
);
} else { } else {
$tabobject->by_object[$tab]->foreignKeyUpdate( $tabobject->by_object[$tab]->foreignKeyUpdate(
$ofield, $ofield,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment