Issue Bug Closed

#54323$GLOBALS['TYPO3_DB']->isConnected() doesn't work when MySQL server has gone away

Bill Dagou 12/11/13, 10:12 updated 10/02/18, 12:09

Description

Dear TYPO3 Team,

Thank you for your great work on TYPO3, it’s really a powerful CMS I could tell.

When I was working on my own extension, I found a DB problem with CLI, not sure whether it would happen in web or not.

The situation is, I was using both cUrl and sleep in my code, and I would get “MySQL server has gone away” error while $GLOBALS[‘TYPO3_DB’]->isConnected() could not detect it. And the code logic is as follow.

———————————————- Code logic start —————————————————-
// cUrl a captcha image and save it to the server
……….

do {
sleep(15); // Set 15 seconds delay for manually enter the captcha code in captcha.txt file.

// Load the content of captcha.txt and set it to $captcha
………
} while (!$captcha);

// cUrl the login page with $captcha
………

// Get the page content and insert it into the database
$GLOBALS[‘TYPO3’]->exec_INSERTquery(‘table’, $insertArray);
———————————————- Code logic end —————————————————-

I think the problem is $GLOBALS[‘TYPO3_DB’]->isConnected() is returning $this->isConnected rather than checking the real connection. And what I do now is $GLOBALS[‘TYPO3_DB’]->__sleep() before the db operation.

BTW, if I choose the wrong project, please help to correct it. There are a lot in the list, and I don’t know which one to choose :)

Cheers,
Bill

Reviews 1