Wanted to share this here because I figured it would help others debug in the future.
The problem is with the Zoo Visitor extension- it's the session_start() function right at the beginning of the file. The server chokes on it- it also chokes on the example from the PHP docs in a completely standalone form. So my suggestion was to take it to the server admin and get that squared away on their end.
The debugging was quirky because if you took out all the code from the zoo visitor function called by the hook and just returned- it was still timing out. That made it seem the problem couldn't be with that extension.
So- I disabled all other functions using that hook:
update exp_extensions set enabled = 'n' where hook = 'sessions_end' and class != 'Zoo_visitor_ext'
Then- found the hook in libraries/Sessions.php and did some debugging:
exit('done 1');
// -------------------------------------------
// 'sessions_end' hook.
// - Modify the user's session/member data.
// - Additional Session or Login methods (ex: log in to other system)
//
ee()->extensions->universal_call('sessions_end', $this);
if (ee()->extensions->end_script === TRUE) return;
//
// -------------------------------------------
exit('done 2');
Likewise, the function in zoo visitor had an exit. 'done 1' was fast. Comment that out- we timed out before the exit in the extension.
So- went to the Extensions library- and by the process of elimination, found that where it slows down is where it includes the extension file:
// Include File
if ( ! class_exists($class_name))
{
require $extension_path;
}
The path was fine, so I pulled all of the code out of ext.zoo_visitor.php and just echoed out a 'hello'. That worked fine as far as timing out went. So then it was just going through the file and finding the issue- which was the session_start().
Make sense? It was a weird one.
We can finish this one off in support, Sam. But I figured it was worth the time to lay out how to track this one down since it was so slippery!