I have been testing my Elgg3.2 site after upgrading it from my production site (Elgg2.3.7). I overwrote the notification hooks ie. blog. Below is my code in my custom plugin.
elgg_unregister_plugin_hook_handler('prepare', 'notification:publish:object:blog', 'blog_prepare_notification');
elgg_register_plugin_hook_handler('prepare', 'notification:publish:object:blog', 'blog_custom_notification');
function blog_custom_notification (\Elgg\Hook $hook) {
$entity = $hook->getParam('object');
$url = $entity->getURL( );
.....
}
My question is why $url returns https://<ip address>/blog/view/<entity guid>/<blog title> instead of https://<dns name>/blog/view/<entity guid>/<blog title>.
Below is how I upgraded from Elgg2.3 to Elgg3.2 (if this helps in debugging).
- Got my production site to work on my test environment first including database and data directory
- In my wwwroot directory, I ran:
1. composer self-update
2. composer require elgg/elgg:~3.2.2
3. composer update
4. vendor/bin/elgg-cli upgrade async -v
Thanks for your help as always.
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.
- seri_ng@seri_ng

seri_ng - 0 likes
- Jerome Bakker@jeabakker

Jerome Bakker - 0 likes
- seri_ng@seri_ng

seri_ng - 0 likes
- Nikolai Shcherbin@rivervanrain

Nikolai Shcherbin - 0 likes
- seri_ng@seri_ng

seri_ng - 0 likes
- Nikolai Shcherbin@rivervanrain

Nikolai Shcherbin - 0 likes
- seri_ng@seri_ng

seri_ng - 0 likes
You must log in to post replies.Additional debugging details I did were including:
1. error_log($blog->getURL( )); in mod/blog/actions/blog/save.php. It printed out expected URL format: https://sitename/blog/view/<entity_guid>/<blog title>
2. error_log($entity->getURL( )); in blog_prepare_notification( ) in mod/blog/start.php. It printed out unexpected URL format: https://<ip address>/blog/view/<entity_guid>/<blog title>
In your migration to Elgg 3.x did you add values for wwwroot, path and dataroot to your settings.php?
See http://learn.elgg.org/en/stable/appendix/upgrade-notes/2.x-to-3.0.html#miscellaneous-api-changes
It can be that the ELgg site doesn't detect your website url correctly, set this in the settings.php and maybe it helps
Thanks Jerome!
In my settings.php file, wwwroot is set to DNS name not IP address and dataroot is set with read/write/execute permission. I believe I have my settings.php set correctly otherwise when I did No.1 from my previous comment, it would return IP address instead of expected URL.
1 - Error in your code. Need:
2 - Test with another entity, e.g.:
Thanks for your advice RvR. I tried both suggestions.
$entity = $hook->getParam('event')->getObject( );
$owner = $entity->getOwnerEntity( );
error_log($entity->getURL( ));
//Result: https://<ip address>/blog/view/<entity guid>/<entity title>
error_log($owner->getURL( ));
//Result: https://<ip address>/profile/<username>
Well, your problem isn't a code but the settings or server' configuration.
There's same discussion.
Edit: Perhaps, you must run the additional commands using composer to update ALL packages not only Elgg.
Read this.
$CONFIG->wwwroot is set to 'https://mysite/'. So I think elgg-config/settings.php is not a problem but I am not certain about my server configuration - I have to debug some more on it.
When I did my Elgg3.2 upgrade, I ran 'composer update' to update ALL packages not 'composer update elgg/elgg'.
Thanks for your advice RvR!