Hello.
I'm trying to make the plugin hook [event: created, river] for Elgg 3:
elgg_register_event_handler('created', 'river', function (\Elgg\Event $event) {
$item = $event->getObject();
if ($item instanceof \ElggRiverItem) {
elgg_log('test', 'ERROR');
}
});
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- ronnim@ronnim
ronnim - 0 likes
Then added a blog and checked it using the 'Inspect this entity' option. Nothing (
- Jerome Bakker@jeabakker
Jerome Bakker - 1 like
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- ronnim@ronnim
ronnim - 0 likes
- iionly@iionly
iionly - 1 like
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 1 like
- Jerome Bakker@jeabakker
Jerome Bakker - 1 like
- ronnim@ronnim
ronnim - 0 likes
- Jerome Bakker@jeabakker
Jerome Bakker - 0 likes
You must log in to post replies.Just to be clear I've tried this test in https://github.com/Elgg/Elgg/blob/3.3/engine/lib/river.php#L303:
The plugin where you're trying is active?
Have you flushed the caches?
When you added the blog did you also publish it, so it's not a draft? Because the river activity for blogs is only created during publishing.
Confirmed. This hook does nothing.
Hello, Jerome.
Yes, of course. I've done it all many times before.
It seems it's a bug in Elgg 3 within the elgg_create_river_item() function. The event gets triggered only at the very end of this function. But before these lines of codes are reached there's a check if the function was called with the return_item option set to true. I think this option is nowhere used in Elgg core for any river item creation. And with the option not being true (default is supposed to be false) the execution of the function never reaches the event trigger.
In Elgg 2 the code was different, i.e. the return_item option was checked only at the very end of the function after the event has been triggered. So, I would think a regression has been introduced in Elgg 3 resulting in the "created", "river" event no longer working.
The problem needs to be fixed in core, so I'll open an issue about it on github.
Open PR
PR is merged, so in the next release of Elgg this will be fixed
Guys, thank you so much!
Elgg 3.3.12 has been released with the fix.
https://elgg.org/blog/view/3073312/elgg-3312