[TYPO3-core] RFC #11770: Feature: mysql_ping wrapper
Dan Osipov
dosipov at phillyburbs.com
Mon Aug 24 21:08:16 CEST 2009
> Ries van Twisk wrote:
>>
>>
>> One potential problem I see with this function is that mysql_ping can
>> reconnect!!!! (really stupid decission of these people.....)
>>
>> "Checks whether or not the connection to the server is working. If it
>> has gone down, an automatic reconnection is attempted. This function
>> can be used by scripts that remain idle for a long while, to check
>> whether or not the server has closed the connection and reconnect if
>> necessary."
>>
>> that means that the function sql_ping does a double connect!!!! THis
>> doesn't sounds right to me.....
>
> I think the manual is wrong. I've used the function on several versions
> of MySQL, and it returns FALSE instead of reconnecting. That's why I
> implemented a reconnection procedure.
>
Also, if it did reconnect as described, mysql_ping would return TRUE, in
which case the reconnection will not happen.
>>
>>
>>
>> Ries
>>
>>
>> On Aug 24, 2009, at 12:13 PM, Dan Osipov wrote:
>>
>>> Thanks,
>>> Attached is the CGL modified patch
>>>
>>> Dan Osipov
>>> Calkins Media
>>> http://danosipov.com/blog/
>>>
>>> Xavier Perseguers wrote:
>>>> Hi,
>>>> Dan Osipov wrote:
>>>>> Attached is the updated patch that includes the DBAL
>>>>> implementation. Since nothing equivalent to mysql_ping exists in
>>>>> adodb, the function will return true for all other handlers.
>>>> I'm OK with this solution as it is what I suggested in the mail I
>>>> sent you.
>>>> However, I would like CGL to be applied (no tab before {, string
>>>> comparison with === instead of ==, boolean false as FALSE, just as
>>>> typed in comment)
>>>> Regards
>>> Index: t3lib/class.t3lib_db.php
>>> ===================================================================
>>> --- t3lib/class.t3lib_db.php (revision 5810)
>>> +++ t3lib/class.t3lib_db.php (working copy)
>>> @@ -981,6 +981,22 @@
>>> }
>>> return $ret;
>>> }
>>> + + /**
>>> + * Ping MySQL database to check if the connection is still alive.
>>> Reconnect if necessary
>>> + * mysql_ping() wrapper function
>>> + *
>>> + * @param bool TRUE if reconnect should be attempted
>>> + * @return mixed Either result of mysql_ping, or new
>>> connection ID if asked to reconnect.
>>> + */
>>> + function sql_ping($reconnect = FALSE) {
>>> + $pingResult = mysql_ping($this->link);
>>> + if (!$pingResult && $reconnect) {
>>> + return $this->sql_pconnect(TYPO3_db_host,
>>> TYPO3_db_username, TYPO3_db_password);
>>> + }
>>> + + return $pingResult;
>>> + }
>>>
>>>
>>>
>>> Index: typo3/sysext/dbal/class.ux_t3lib_db.php
>>> ===================================================================
>>> --- typo3/sysext/dbal/class.ux_t3lib_db.php (revision 5810)
>>> +++ typo3/sysext/dbal/class.ux_t3lib_db.php (working copy)
>>> @@ -1651,6 +1651,27 @@
>>> function sql_select_db($TYPO3_db) {
>>> return TRUE;
>>> }
>>> + + /**
>>> + * Ping the database to check if the connection is still alive.
>>> Reconnect if necessary
>>> + * Only _DEFAULT handler is supported. Returns TRUE for other
>>> handlers
>>> + *
>>> + * @param bool TRUE if reconnect should be attempted
>>> + * @return mixed Either result of mysql_ping, or new
>>> connection ID if asked to reconnect.
>>> + */ + function sql_ping($reconnect = FALSE) {
>>> + if ($this->handlerCfg['_DEFAULT']['type'] === 'native') {
>>> + $pingResult = mysql_ping($this->link);
>>> + if (!$pingResult && $reconnect) {
>>> + return $this->sql_pconnect(TYPO3_db_host,
>>> TYPO3_db_username, TYPO3_db_password);
>>> + }
>>> + + return $pingResult;
>>> + }
>>> + else {
>>> + return TRUE;
>>> + }
>>> + }
>>>
>>>
>>>
>>> @@ -1665,7 +1686,6 @@
>>>
>>>
>>>
>>> -
>>> /**************************************
>>> *
>>> * SQL admin functions
>>> _______________________________________________
>>> Before posting to this list, please have a look to the posting rules
>>> on the following websites:
>>>
>>> http://typo3.org/teams/core/core-mailinglist-rules/
>>> http://typo3.org/development/bug-fixing/diff-and-patch/
>>> _______________________________________________
>>> TYPO3-team-core mailing list
>>> TYPO3-team-core at lists.netfielders.de
>>> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-team-core
>>
>>
>> regards, Ries van Twisk
>>
>> -------------------------------------------------------------------------------------------------
>>
>> tags: Freelance TYPO3 Glassfish JasperReports JasperETL Flex Blaze-DS
>> WebORB PostgreSQL DB-Architect
>> email: ries at vantwisk.nl web: http://www.rvantwisk.nl/
>> skype: callto://r.vantwisk
>> Phone: +1-810-476-4196 Cell: +593 9901 7694 SIP:
>> +1-747-690-5133
>>
>>
>>
>>
>>
>>
>>
More information about the TYPO3-team-core
mailing list