[BUGFIX] Create history record only with valid log uid

To prevent a sql error the insert query for creating sys_history
records in Datahandler must only be executed, if argument
$logId is a valid uid. This could happen, if logging in
Datahandler is disabled.

Resolves: #55472
Releases: 6.2
Change-Id: Idacced5cb0af24a6c9f34165a8d0598ae9c91998
Reviewed-on: https://review.typo3.org/27162
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters