New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

J3.4.7: Fatal error about connection->stat() not existing on external database connections #8762

Closed
ghost opened this Issue Dec 22, 2015 · 7 comments

Comments

Projects
None yet
6 participants
@ghost
Copy link

ghost commented Dec 22, 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)

@ghost ghost changed the 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 Dec 22, 2015

@pollen8

This comment has been minimized.

Copy link
Contributor

pollen8 commented Dec 22, 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.

@pollen8

This comment has been minimized.

Copy link
Contributor

pollen8 commented Dec 22, 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.

@cheesegrits

This comment has been minimized.

Copy link
Contributor

cheesegrits commented Dec 22, 2015

Confirmed issue and fix.

-- hugh


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

This comment has been minimized.

Copy link
Contributor

andrepereiradasilva commented Dec 22, 2015

Confirmed issue and fix.

@creativeprogramming

This comment has been minimized.

Copy link

creativeprogramming commented Dec 23, 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);

@wilsonge

This comment has been minimized.

Copy link
Contributor

wilsonge commented Dec 24, 2015

This was fixed by #8774

@wilsonge wilsonge closed this Dec 24, 2015

@wilsonge

This comment has been minimized.

Copy link
Contributor

wilsonge commented Dec 24, 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 :)

@joomla joomla deleted a comment from alo24h Jan 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment