? Pending

User tests: Successful: Unsuccessful:

avatar alikon
alikon
14 Mar 2018

Pull Request for Issue #19906 .

Summary of Changes

use strict comparison

Testing Instructions

see #19906

avatar alikon alikon - open - 14 Mar 2018
avatar alikon alikon - change - 14 Mar 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 14 Mar 2018
Category Libraries
avatar mbabker
mbabker - comment - 14 Mar 2018

Considering the event dispatcher hasn't changed in a long time, I'd like to know what's actually causing this issue.

avatar alikon
alikon - comment - 14 Mar 2018

i was asking myself the same thing without a quick answer
but the fix is so easy so ...

avatar mbabker
mbabker - comment - 14 Mar 2018

Fixing code is easy. If we don't understand why things are getting broken, all we're doing is hacking around things. Is this indicative of another issue that's just going to be ignored by changing a line of code in a class that has had no meaningful change in months (years?) or just a long standing bug that never exposed itself?

avatar alikon
alikon - comment - 14 Mar 2018

Fixing code is easy

sometimes is not ? unfortunately

not sure i'm able to answer your legit question, but in this specific case the "hack"
should be not "harmfull" .... at least

avatar mbabker
mbabker - comment - 14 Mar 2018

I don't think it's harmful I'm just annoyed with continuously seeing fixes for things that randomly broke and nobody can explain why it's broken. Understanding why something is broken by changes in unrelated code helps make sure the same types of problems don't come back later on.

avatar MurilloAGoncalves
MurilloAGoncalves - comment - 14 Mar 2018

I can't confirm exactly why was this happening.
But it's a page with lots of components. I'm using the template and components from RocketTheme: RokSprocket, RokGallery...
Logging the _observers array, from that method, it got huge! In some way, a circular reference happens in the comparison with the handlers

avatar alikon
alikon - comment - 14 Mar 2018

we have understood a "cure", but speaking for myself, not the root issue,
can you give us more details ?

cause as @mbabker pointed out, that lines of code are unchanged from quite sometimes

avatar csthomas
csthomas - comment - 14 Mar 2018

I have tested this item successfully on 9357e74

Despite #19912 IMO this should also be merged.


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

avatar csthomas csthomas - test_item - 14 Mar 2018 - Tested successfully
avatar MurilloAGoncalves
MurilloAGoncalves - comment - 15 Mar 2018

I was wondering if this is a correct fix.
I had approved because it resolved the issue and the error wasn't being displayed anymore. It was even the change I was made on my local code before opened the issue.

But, as in http://php.net/manual/en/language.oop5.object-comparison.php, the identity operator checks whether objects refer to the same instance, that is, if they are in the same memory location, without looking at the values of the properties.
And I don't know if this is the expected behavior in this case...

Am I getting it wrong?

I applied the #19912 and undid #19907 and the error isn't being displayed (maybe correcting the issue).

avatar mbabker
mbabker - comment - 15 Mar 2018

If I'm understanding this correctly then yes, it would be a valid change.

class TestObserver
{
    private $db;

    public function __construct(JDatabaseDriver $db)
    {
        $this->db = $db;
    }

    public function onAfterDispatch()
    {
        // Do stuff
    }
}

Right now, if I tried to attach two instances of this observer to the event dispatcher, if the two observer instances are holding a reference to the same database object then the dispatcher won't add the second observer instance because it will consider it already attached. With the strict comparison, the two separate instances will attach to the observer because it is indeed two separate objects.

I can see why we have the code to try and prevent duplicate observers in the dispatcher, but it isn't necessarily a major issue to allow it either (at worst it would just result in a method being called multiple times).

avatar zero-24 zero-24 - alter_testresult - 19 Mar 2018 - Magisdn: Tested successfully
avatar zero-24
zero-24 - comment - 19 Mar 2018

I have just added the test by @Magisdn


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

avatar Quy Quy - change - 19 Mar 2018
Status Pending Ready to Commit
avatar Quy
Quy - comment - 19 Mar 2018

RTC


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

avatar csthomas
csthomas - comment - 21 Mar 2018

Link to related topic on the forum https://forum.joomla.org/viewtopic.php?f=710&t=960132

avatar mbabker mbabker - change - 25 Mar 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-03-25 14:55:40
Closed_By mbabker
Labels Added: ?
avatar mbabker mbabker - close - 25 Mar 2018
avatar mbabker mbabker - merge - 25 Mar 2018

Add a Comment

Login with GitHub to post a comment