There is no loop, I just misread some class names that are similar. Still don't know what's causing it. At some point either XenForo's DB connection gets closed or the reference to it is severed.
You do need the conditional. If you don't have one it will throw an exception even if the DB connection is working. You only want one when it's not working. Even if you get the setFetchMode error all the time, the function might only be failing one time out of a hundred calls during the same page load. It's the failed call that we're trying to debug.
Are you unable to fill out the Install Service in the Members area? If you submitted that, I could do all this relatively quickly (we will probably need dumps from many functions within the backtrace) and have a fix for you in a few hours.