? Failure

User tests: Successful: Unsuccessful:

avatar asika32764
asika32764
2 Aug 2015

What Happened?

The Pdomysql / Pdo / Oracle and Sqlite driver will unset connection property when disconnect.

But if we reconnect to DB, the connect() method will tell us this error:

 Notice: Undefined property: JDatabaseDriverPdomysql::$connection 

p-2015-08-03-002

How to Resolve?

Set $this->connection = null instead unset it.

How to Test

In any plugin or everywhere, use this code

$db = \JFactory::getDbo();

$db->disconnect();

$db->setQuery('select * from #__content limit 1')->execute();

The PHP will raise Notice message to page.

And it will disappear if apply this patch.

avatar asika32764 asika32764 - open - 2 Aug 2015
avatar asika32764 asika32764 - change - 2 Aug 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 2 Aug 2015
Labels Added: ?
avatar PhilETaylor
PhilETaylor - comment - 2 Aug 2015

I wish I could be more educated in this but Im not - maybe someone like ircmaxwell or someone that understands PHP internals better might want to comment - but I believe (rightly or wrongly) that unset is a lot different under the hood than just setting something to null. Maybe something to do with releasing memory/garbage collection

It just seems wrong to set something as null that was unset before. unset doesn't set something to null and therefore what you are proposing is a change, not a replacement.

I might be wrong - I might be talking our my arse - but it just doesnt feel right.

If I am right, or on the offchance I am, It might be better to unset and then to set as null like this:

   unset($this->connection);
   $this->connection = null;
avatar asika32764
asika32764 - comment - 2 Aug 2015

To my knowledge, if the resource in a property or variable set to null, and no other variable reference to this resource, it will be free and close automatically.

If there are other variables reference to this resource, it will still exists no meter we set origin variable to null or unset it.

By the way, Mysqli use null and work fine for a long time.
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/database/driver/mysqli.php#L212

avatar asika32764
asika32764 - comment - 2 Aug 2015

And null is often considered as not exists or not set

$foo = null;

isset($foo); // false
avatar zero-24 zero-24 - change - 3 Aug 2015
Category Libraries
avatar abuechert abuechert - test_item - 1 Aug 2016 - Tested successfully
avatar abuechert abuechert - test_item - 1 Aug 2016 - Tested successfully
avatar abuechert
abuechert - comment - 1 Aug 2016

I have tested this item successfully on 215d540

tested @icampus wpw pizza, bugs & fun
i used to code in the "How to Test" section in one of my component code. issue did not appear for me, seems to be fixed.


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

avatar brianteeman
brianteeman - comment - 1 Aug 2016

@abuechert were you able to replicate the problem. It's unclear from your report. If you weren't then it can't be a successful test of the pr

avatar abuechert
abuechert - comment - 1 Aug 2016

@brianteeman no i tested with and without the patch, could not see the problem.

avatar brianteeman
brianteeman - comment - 1 Aug 2016

So that is NOT a successful test of the pull request

avatar abuechert abuechert - test_item - 1 Aug 2016 - Tested unsuccessfully
avatar abuechert
abuechert - comment - 1 Aug 2016

I have tested this item 🔴 unsuccessfully on 215d540


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

avatar mehmetalipamukci mehmetalipamukci - test_item - 1 Aug 2016 - Tested unsuccessfully
avatar mehmetalipamukci
mehmetalipamukci - comment - 1 Aug 2016

I have tested this item 🔴 unsuccessfully on 215d540

tested @icampus
cant reproduce the error, tested it for components and plugins.


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

avatar roland-d
roland-d - comment - 2 Aug 2016

@asika32764 Can you have a look at this please? Is the issue still valid?


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

avatar asika32764
asika32764 - comment - 2 Aug 2016

I'm not sure, maybe Joomla fixed this in newest version.

I also not meet same problem in recent versions, maybe we can close this PR first, and re-open if anyone report same issue in the future.

Add a Comment

Login with GitHub to post a comment