If you’re using opcache — then it might be the reason.
I’ve disabled opcache and then enabled it.
might be simple restart php-fpm will work.
Had this problem.
I used php-fpm with chroot.
If host name is localhost then mysqli tries to use socket, not port.
But if you chroot your PHP then mysqli can’t find socket where it should be.
MySQL socket is usually /tmp/mysql.sock.
btw, checking if ( !empty($this->to_do) ) before foreach is redutant ‘couse if array is empty, then foreach will do nothing and that’s good.