backport from trunk (rev #9700):
- fixed ugly bug in computing the fromIP and toIP (because of some mixture of STRING and STR type at db level).
  Thanks to Vlad Paiu for assisting with the debugging ;)
  Closes bug #3576351