Here's what I've found so far, all in
functions/import_class.php
-
around line 423:
tbl_lnkHostToHosttemplate's type is 3, not 4, so basically hosttemplates linked to a host are not deleted when importing with overwrite. At least that's what is happening in my case. When importing a host, the
$arrRelations array contains a single relation with type 4, namely
tbl_lnkHostToVariabledefinition.
- this only after a quick survey of the code, so I'm not sure, but you seem to only do an UPDATE of the host entry, SET-ting variables that are actually in the imported file. So if I leave out a variable alltogether, it's value will not change, but it will stay as it were. (
lines 418, then @ line 664 you're parsing only the imported array, checking it against the known object variables. you seem to submit the update query on line 733, without ever adding the undefined variable's default values to the UPDATE)
While I agree that UPDATE is good to keep relations you would want to keep (like group membership for hosts), you should make sure, that all un-included variables are set to their respective defaults, since you're not deleting the original definition (maybe always, or maybe as a choice option in the front-end, that's up to you)
- variables included in the imported file, but with values explicitly set to "null" (I'm not sure if comparison of an empty string with "null" string would work, but I don't think so) are almost working, however, the SQL should be
| Code: |
SET `<fieldname>`=NULL
|
instead of
| Code: |
SET `<fieldname>`='null'
|
as the latter would insert a string instead on NULL value. This is on
line 674