[TYPO3-core] RFC #14275: Bug: Error handler does not catch exception while connecting to DB

Francois Suter fsu-lists at cobweb.ch
Sun May 2 11:03:03 CEST 2010


Hi,

> Solution:
> Wrap the call to connectDB() in a try/catch block and do nothing more.

I realized that I forgot to describe the steps to reproduce, as it is 
not trivial to get into a situation where the effect of this patch can 
be seen:

1) download a dummy package from typo3.org
2) start a new TYPO3 installation
3) check that localconf.php and typo3conf are *not* writable (as they 
should probably be by default)
4) start the 1-2-3 install process
5) you'll get a first exception because localconf.php is not writable. 
This is due to DBAL trying to load itself and should be caught by DBAL 
(a bug report is already opened with regards to this [1] and it is 
actually solved in DBAL SVN).
6) make localconf.php writable and try to continue the process
7) at that point you should get an exception complaining that a 
connection to the database cannot be established (obviously, since we 
haven't entered any credentials yet). The error happens when DBAL tries 
to load itself, as the method it relies on 
(t3lib_install::writeToLocalconf_control()) tries to write a temporary 
file in typo3conf, which is not writable. This creates a PHP error, 
which is caught by the error handler, which tries to write the error to 
the sys_log table. Before that it tries to ensure that a DB connection 
exists, which is impossible at that point. So the exception thrown by 
t3lib_db::connect_DB() should just be caught, but ignored at that point.

About patching 4.3, this is actually not necessary as 
t3lib_db::connect_DB() uses die() in that version. I think we're going 
to find a few more effects of replacing all the die's by exceptions over 
time, but it was still a worthy change, of course.

Cheers

-- 

Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch

[1] http://bugs.typo3.org/view.php?id=14274


More information about the TYPO3-team-core mailing list