[BUGIFX] Ensure that pid is not NULL

In some cases it may happen that the pid cannot be determined
while migrating DAM relations. In such a case, the migration of
those problematic records will fail because a NULL value for the
pid field will make the query fail.

In such cases, fall back to 0 for the pid.
Updated code base by merging upstream/master
[BUGFIX] Wrong category relations

The relations between DAM records and DAM categories is
"inverted" compared to the relation between FAL records and
system categories (inverted usage of uid_local and uid_foreign
fields). The task does not handle this correctly.

Furthermore the relation must be established with the file
metadata rather than with the file itself.
[FEATURE] Migrate advanced metadata

The metadata migration tool from the command controller considers
only basic metadata. If extension filemetadata is loaded, it
should import much more information from the DAM.
Merge commit '47a72eb268163d78b05466dfb0c253be0105fead'

* commit '47a72eb268163d78b05466dfb0c253be0105fead':
  [FEATURE] Migrate advanced metadata
  [BUGFIX] Wrong category relations
  [BUGIFX] Ensure that pid is not NULL