catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

MySQL Call error after 6-10 hours (idk) #979

Closed J1b1x closed 3 years ago

J1b1x commented 3 years ago

Information

Describe the Problem I have a PocketMine-MP Server (for Minecraft bedrock edition) and if I don't restart the server after 6-10 hours (idk the exact time) this error appears:

TypeError: "Return value of Jibix\SecuritySystem\util\Database::getMutedPlayer() must be of the type array or null, bool returned

the function returns a boolean (false) but idk why ._.

(that's not the only function that has this problem after few hours and it still the same error)

If I restart the server then, it works perfectly fine and it returns the desired array.

Detail Code

public function getMutedPlayers(): array {

    $array = [];
    $result = $this->getMedoo()->select("users", ["name"], ["muted" => true]);

    if (count($result) != 0) {
        foreach ($result as $item) {
            $array[] = $this->getPlugin()->getGroupSystem()->getUtils()->getGroupTag($item);
        }
    }

    return $array;
}

Expected output it returns a boolean (false)

Ps: Sorry for my bad English, I come from Germany

catfan commented 3 years ago

Check out getMedoo() to return the Medoo object correctly.

You may need to reconnect or recreate it if the database connection is gone.