Implemented disconnect() method in Db adaptor

digitalpoint

Well-known member
While it's not hard to add with a custom adaptor that extends the normal one, I can think of some use cases beyond my own where you might want to disconnect from the db server, especially when you are using XF as a framework for other applications. For my case, I have something that reads some info from the database, does it's thing (which can take a few minutes) and then update the database once that is done. I'm disconnecting from the database, rather than hold the connection open (could be real problematic if you have multiple of these processes going on at once). Just extended the default adapter to give me a disconnect method:

PHP:
public function disconnect()
{
   if ($this->isConnected())
   {
      $this->getConnection()->close();
      $this->connection = null;
   }

   return true;
}
 
Upvote 9
This suggestion has been implemented. Votes are no longer accepted.
I've just noticed the lack of this is sitll the case for XF2.0RC3

If XenForo is going todo forking on the CLI for multiple workers, it will need to ensure the database connection is closed before forking, or you get very weird results (same for any cache provider).
 
Back
Top Bottom