From: Jean Baptiste Favre Date: Thu, 20 Jun 2013 09:07:51 +0000 (+0200) Subject: PHP 5.4: Fix 'mysql has gone away' error when using mysqli driver with forked daemons... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=723f0f19295ef40106d18fbd59033a892b7b5b13;p=quix0rs-gnu-social.git PHP 5.4: Fix 'mysql has gone away' error when using mysqli driver with forked daemons (at least TwitterBridge) --- diff --git a/lib/daemon.php b/lib/daemon.php index 4c2491e97b..c09531c9d5 100644 --- a/lib/daemon.php +++ b/lib/daemon.php @@ -48,6 +48,17 @@ class Daemon function background() { + /* Starting PHP 5.4 (dotdeb), maybe earlier for some version/distrib + * seems MySQL connection using mysqli driver get lost when fork. + * Need to unset it so that child process recreate it. + * + * Not needed if using mysql driver (but it's deprecated starting PHP 5.5) + * + * @todo FIXME cleaner way to do it ? + */ + global $_DB_DATAOBJECT; + unset($_DB_DATAOBJECT['CONNECTIONS']); + $pid = pcntl_fork(); if ($pid < 0) { // error common_log(LOG_ERR, "Could not fork.");