User tests: Successful: Unsuccessful:
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
Set $this->connection = null
instead unset it.
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.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
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
And null
is often considered as not exists
or not set
$foo = null;
isset($foo); // false
Category | ⇒ | Libraries |
I have tested this item
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.
@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
@brianteeman no i tested with and without the patch, could not see the problem.
So that is NOT a successful test of the pull request
I have tested this item
I have tested this item
tested @icampus
cant reproduce the error, tested it for components and plugins.
@asika32764 Can you have a look at this please? Is the issue still valid?
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.
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 collectionIt 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: