We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

difference between EventManager bind and call | Forum

Marcus
Marcus Dec 24 '20

Hi folks need some developer to explain me the difference between OW::getEventManager()->bind and OW::getEventManager()->call


Looks like call is limited to only one bind! If so then whats the point of using it?

The Forum post is edited by Marcus Dec 24 '20
dave Leader
dave Dec 25 '20

it appears that call is used just for the last event listener and gets its value, so the fact that it only does one is a good thing, as the result will only be one


check out   ow_core/event_manage.php line 251



Marcus
Marcus Dec 25 '20

Thanks dave.


Actually its not good thing!


This stuff should be restricted and not available for binding!


Yes it only grabs last event listener but if you bind to that event your function gonna be be the last one and the event this call was intended to never gets fired up!


I have noticed this in groups plugin!


It uses call function to call feed.add_follow.


I also need to bind to that event, that makes my function work but not the newsfeed.


This brakes down groups follow code and pretty much messes everything up!

dave Leader
dave Dec 26 '20
Do you have to bind, why not just grab the instance, use it, and move on... is that not possible with your task?
Marcus
Marcus Dec 27 '20
appreciate it dave. could u pls give me an example? 
dave Leader
dave Dec 29 '20
yep sure, ill get an example to you tonight...
dave Leader
dave Dec 30 '20
Well marcus i will have to eat some crow on this one... i could not get an example to work at all.. you are right its really messed up... sorry
Marcus
Marcus Jan 6 '21
Quote from dave Well marcus i will have to eat some crow on this one... i could not get an example to work at all.. you are right its really messed up... sorry
Appreciate it dave. Happy new year man. 
Marcus
Marcus Jan 6 '21
There is no poit of using call función as u can simply and safely use getInstance()-someFunction
Marcus
Marcus Jan 6 '21
Also... whats the point of using service.php together with dao.php as a relay sort of speaking when u can access all functions of dao bypassing service.php. The idea is good but it was poorly designed. 
dave Leader
dave Jan 13 '21

I agree it is poorly executed, the design works if done correctly.  The way it is suppose to work is that if the request is not from the service file then it fails do to class protection. 


The service file is public but the dao file is protected, so it allows for a extension of the protected class from the service file but no other file should be able to access the db queries in the dao file.  


However it is broken and this is why there is a security risk with Oxwall.     There is a proper way to do it as i have done it on a project myself, and any time there is a query request anywhere other than from the service file, it fails, that is the proper way. 

The Forum post is edited by dave Jan 13 '21