|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #78555 Disable dblink cleanup
Submitted: 2019-09-17 17:20 UTC Modified: 2021-08-05 12:09 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: erik at coretech dot se Assigned:
Status: Open Package: MySQLi related
PHP Version: 7.3.9 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: erik at coretech dot se
New email:
PHP Version: OS:


 [2019-09-17 17:20 UTC] erik at coretech dot se
When building daemon processes with php that requires the parent process to create a persistent database connection. The cleanup of the child process closes the parents database connection. A way to disable this cleanup on a object basis would make php better for daemon projects. This problem applies to other file descriptors aswell but the most problematic is the mysqli dblink resource.

Test script:

function query_db($dbo) {

        if(!mysqli_real_query($dbo, "SELECT 1"))
                die("Unable to query database: " . mysqli_error($dbo) . " (" . mysqli_errno($dbo) . ")\n");

        if(($res = mysqli_store_result($dbo)) === FALSE)
                die("Unable to store result: " . mysqli_error($dbo) . " (" . mysqli_errno($dbo) . ")\n");

        echo "Successful query\n";

$dbo = mysqli_init();
if (!mysqli_real_connect($dbo, 'dbserver', 'dbuser', 'dbpwd')) {
        die("Unable to connect to the database\n");


$pid = pcntl_fork();
if ($pid == -1) {
        die("Could not fork\n");
} else if($pid) {
        // Parent
} else {
        // Child
        // mysqli_disable_cleanup($dbo, TRUE);

Expected result:
Successful query
Successful query

Actual result:
Successful query
PHP Warning:  mysqli_real_query(): MySQL server has gone away in /tmp/test.php on line 5
PHP Warning:  mysqli_real_query(): Error reading result set's header in /tmp/test.php on line 5
Unable to query database: MySQL server has gone away (2006)


mysqli_dbo_cleanup (last revision 2019-09-17 17:24 UTC by erik at coretech dot se)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-17 17:24 UTC] erik at coretech dot se
The following patch has been added/updated:

Patch Name: mysqli_dbo_cleanup
Revision:   1568741061
 [2021-08-05 12:09 UTC]
Consider to provide the patch as pull request[1] for better

[1] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 22:01:30 2024 UTC