When creating an external database connection with JDatabase::getInstance(), it is possible the connection is not created. However since the new Joomla 3.4.7, the disconnect() method (mysqli) tries to check for $this->connection->stat().
This fails and throws an error when $this->connection is empty.
Fatal error: Call to a member function stat() on a non-object in .../libraries/joomla/database/driver/mysqli.php on line 202
I have hacked this solution into my website now:
/libraries/joomla/database/driver/mysqli.php line 202:
if (!empty($this->connection) && $this->connection->stat() !== false)
Title |
|
FYI George is going to apply the 3.4.7 changes to the staging branch tonight, at which point I'll make a PR
Confirmed issue and fix.
-- hugh
Confirmed issue and fix.
On this i want to tell you that on some of my sites I'd a similar issue also in joomla < 3.4.7: a warning was issued for 'already closed connection' (i don't remember the exact message) on the
mysqli_close($this->connection);
line
i always put this to prevent it:
@mysqli_close($this->connection);
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-12-24 11:30:42 |
Closed_By | ⇒ | wilsonge |
We've slightly reworked this check in 3289e7d based on some feedback that we still occasionally got
Fatal error: Uncaught Error: Call to a member function stat() on boolean in libraries/joomla/database/driver/mysqli.php on line 219
from the stack trace it seemed to happen in a scenario where either the class was instantiated and never connects (i got it on the first page of the installer, there’s no DB connection at all there) or disconnects before the destructor is called.
I got the Fabrik team to test this as well before committing it. But if any other's in here have any time to check as well all the better :)
Test case:
Install Fabrik from github: github.com/Fabrik/fabrik/
Log into admin and then view this url:
administrator/index.php?option=com_fabrik&task=contenttype.preview&contentType=default.xml
The bug produces the error:
" Fatal error: Call to a member function stat() on null in F:\Users\rob\PhpstormProjects\fabrik31x\public_html\libraries\joomla\database\driver\mysqli.php on line 202"
After Peter's suggested fix the same page no longer produces an error.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8762.