This is not good for scalability, and we should only open connections to the db when needed.
The rrors is in index.php: the opening of the session is still intertwined with the dbRequired required variable and with the opening of the connection to the db.
- $dbRequired and $sessionrequired should not be related anymore (line 410-413)
- on line 416, open a connection to the db if $dbRequired, but do not do anything wrt session
- immediately afterwards, start session if sessionRequired && $ini->variable( 'Session', 'ForceStart' ) === 'enabled'