avoid dialplan loop

See bug #4887 for details
Merge branch '4887-dialplan-loop'