Bug #19407
closedCalling of mysql_connect needs to check that mysql extension exists
0%
Description
In this class.t3lib_db.php, at line 898 is the following code:
function sql_pconnect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password) {
// mysql_error() is tied to an established connection
// if the connection fails we need a different method to get the error message
ini_set('track_errors', 1);
ini_set('html_errors', 0);
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect']) {
$this->link = @mysql_connect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password);
} else {
$this->link = @mysql_pconnect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password);
}
However, this assumes that mysql is installed.
My installation has mysqli and PDO installed only. Therefore, the code above simply crashes, with an error 500. I would suggest adding an
if (!extension_loaded ('mysql')) {/* Report error */}
check just before using the first mysql_ call.
Furthermore, no error appears in the logs, because you have used the silencing operator. I would suggest doing an ini_set ('display_errors', 0); then removing the silencing operator, then an ini_restore. This way the problem will appear in the logs but not on the screen.
Supporting mysqli is a secondary issue also. But the above should at least help people diagnose what the problem is, rather than getting a blank screen and no log warning.
(issue imported from #M9470)
Updated by Xavier Perseguers about 16 years ago
Hello, your description of the solution seems correct.
Please post a patch that will add this test instead of just explaining. This way the likelihood this issue is being fixed will be much greater. You should post to the core list too as explained on http://typo3.org/development/bug-fixing/resolving-bugs/
Updated by Dmitry Dulepov about 16 years ago
TYPO3 has certain system requirements that you must fulfil before you use TYPO3. It is the same like a requirement to have electrical socket in the house to use refrigerator. Having mysql is one of such requirements. Therefore TYPO3 will not have such checks. If you do not fulfil the requirements, you should not run TYPO3.