?
avatar ghost
ghost
22 Dec 2015

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)

Votes

# of Users Experiencing Issue
2/2
Average Importance Score
4.50

avatar nonumber nonumber - open - 22 Dec 2015
avatar nonumber nonumber - change - 22 Dec 2015
Title
J3.4.7: Error about connection->stat() not existing on external database connections
J3.4.7: Fatal error about connection->stat() not existing on external database connections
avatar pollen8
pollen8 - comment - 22 Dec 2015

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.

avatar pollen8
pollen8 - comment - 22 Dec 2015

FYI George is going to apply the 3.4.7 changes to the staging branch tonight, at which point I'll make a PR


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8762.

avatar cheesegrits
cheesegrits - comment - 22 Dec 2015

Confirmed issue and fix.

-- hugh


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8762.

avatar andrepereiradasilva
andrepereiradasilva - comment - 22 Dec 2015

Confirmed issue and fix.

avatar creativeprogramming
creativeprogramming - comment - 23 Dec 2015

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);

avatar wilsonge
wilsonge - comment - 24 Dec 2015

This was fixed by #8774

avatar wilsonge wilsonge - change - 24 Dec 2015
Status New Closed
Closed_Date 0000-00-00 00:00:00 2015-12-24 11:30:42
Closed_By wilsonge
avatar wilsonge wilsonge - close - 24 Dec 2015
avatar wilsonge wilsonge - close - 24 Dec 2015
avatar wilsonge
wilsonge - comment - 24 Dec 2015

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 :)

Add a Comment

Login with GitHub to post a comment