From 4.x to 5.0
Contents
CKEditor
The editor has been updated to version 5. This brings some new features (like mentions and images in content) but also impacts existing plugins. Most notable are The Wire (which now also has mention support) and the removal of the Embed plugin.
The related ‘longtext’ menu is no longer available.
Composer
PHP Requirements
The minimal PHP version is now 8.0.
Faker
The faker library is no longer maintained by fzaninotto so we switched to a fork which is maintained by FakerPHP.
Events and Hooks
These two similar concepts have been merged and from now on we will only refer to events. The public service hooks no longer exists.
All hooks can now be registered in the events section of your plugin.
If you use hook callbacks that expect a type hinted ElggHook argument you will need to update this to ElggEvent.
Create event
The create, <object|group|user|site> events can no longer be used to prevent the creation of the entity.
Use create:before if you wish to prevent the creation.
Private Settings
The concept of private settings has been removed from the system. All private settings have been copied to metadata. All related functions have been removed.
Upgrades
Async or system upgrades are no longer classes that implement interfaces but extend abstract classes. Update your upgrades to extend the correct classes.
The reason for this change is to be able to access the ElggUpgrade entity from the Batch that runs a part of the upgrade.
You can access the upgrade by calling $this->getUpgrade().
Session
If you use the session service directly (or via elgg_get_session()) you might need to update your code. Various functions of this class have been moved to the elgg()->session_manager service.
Gatekeepers
The PageOwnerCanEditGatekeeper middleware now requires a pageowner to be set. This gatekeeper now also requires a logged in user at all times.
Files plugin
Files uploaded using the file plugin are no longer stored with the owner but with the file entity. File icons have also been changed. Icon images are only available for image file types. Icon sizes have been changed to use the default icon sizes.
Embed plugin
The embed plugin has been removed.
Javascript
Hooks system
The javascript hook functions have been moved to an AMD module. If you used javascript hooks than you need to update your code to use the elgg/hook module.
The concept of ‘instant hooks’ is no longer present in the system.
The 'init', 'system' event is no longer triggered in javascript.
Removed functions
elgg.is_in_object_arrayelgg.is_instant_hookelgg.is_triggered_hookelgg.push_to_object_arrayelgg.register_hook_handleruse theregisterfunction provide by theelgg\hooksmoduleelgg.register_instant_hookelgg.set_triggered_hookelgg.trigger_hookuse thetriggerfunction provided by theelgg\hooksmodule
Exceptions
The uses of exceptions in Elgg has been revisited. The \Elgg\Exceptions\InvalidParameterException has been removed and replaced with the correct exception.
Also the use of the \Elgg\Exceptions\InvalidArgumentException has been checked. In some cases the exception was replaced by a more appropriate exception.
ElggRiverItem
It’s no longer allowed to set arbitrary data during runtime on an ElggRiverItem. Since the data was only available during runtime and not saved to the database this distinction has been removed.
When setting an unsupported attribute an \Elgg\Exceptions\RuntimeException is thrown.
// this is allowed
$item = new \ElggRiverItem();
$item->subject_guid = elgg_get_logged_in_user_guid();
// this is no longer allowed (causes an \Elgg\Exceptions\RuntimeException)
$item = new \ElggRiverItem();
$item->foo = 'bar';
Metadata options in getter functions
Previously there was a magic that would turn the metadata_value string into an array if it contained an ,.
This magic has been removed. You now need to provide the array yourself. Because of this magic it was impossible to
query for a metadata value that contained an ,.
// previously
$options = [
'metadata_name_value_pairs' => [
'some_name' => 'some_value1, some_value2',
],
];
// would result into, thus giving it an OR value
$options = [
'metadata_name_value_pairs' => [
'name' => 'some_name',
'value' => [
'some_value1',
'some_value2',
],
'operand' => '=',
],
];
Changes in functions
The following functions now have their arguments and/or return types type-hinted, this can cause TypeError errors.
Also some class functions have their return value type hinted and you should update your function definition.
Some function might have their arguments changed or the return type has been changed.
Lib functions return types
elgg_add_admin_notice()now returnsnullon failure instead of aboolelgg_create_river_item()now returnsnullon failure or anElggRiverItemelgg_delete_metadata()no longer returnsnullelgg_delete_river()no longer returnsnullelgg_deprecated_notice()no longer returnsboolelgg_generate_entity_url()now returnsnullon failure instead of aboolelgg_generate_url()now returnsnullon failure instead of aboolelgg_get_annotation_from_id()now returnsnullif no annotation is found instead of aboolelgg_get_download_url()now returnsnullif there is an errorelgg_get_entity_as_row()now returnsnullif no entity is found instead of aboolelgg_get_entity_dates()no longer returns aboolelgg_get_form_footer()no longer returns aboolelgg_get_inline_url()now returnsnullif there is an errorelgg_get_metadata_from_id()now returnsnullif no metadata could be foundelgg_get_page_owner_entity()now returnsnullif page owner could not be foundelgg_get_river_item_from_id()now returnsnullif no river item could be foundelgg_get_system_cache()now returns an instance of\Elgg\Cache\BaseCacheinstead of an\ElggCacheelgg_get_uploaded_file()now returnsnullif no file could be found or the file was invalidelgg_normalize_site_url()now returnsnullwhen the url is not a site urlelgg_register_action()no longer returns aboolelgg_register_menu_item()no longer has a return valueelgg_register_widget_type()no longer has a return valueelgg_set_form_footer()no longer has a return valueelgg_trigger_after_event()no longer has a return valueelgg_unregister_action()no longer has a return valueelgg_unregister_event_handler()no longer has a return valueelgg_unregister_notification_event()no longer has a return valueelgg_unregister_notification_method()no longer has a return valueelgg_unregister_widget_type()no longer has a return valueelgg_view_annotation()no longer returns aboolelgg_view_comments()no longer returns aboolelgg_view_list_item()no longer returns aboolelgg_view_relationship()no longer returns aboolget_entity()now returnsnullif no entity is found instead of aboolget_user()now returnsnullif no user is found instead of aboolelgg_ws_expose_function()no longer returns abool
Lib functions function parameters
blog_prepare_form_vars()now requires aElggBlogfor$blogand aElggAnnotationfor$revisionbookmarks_prepare_form_vars()now requires aElggBookmarkfor$bookmarkdiscussion_prepare_form_vars()now requires aElggDiscussionfor$topicelgg_add_action_tokens_to_url()now requires astringfor$urland aboolfor$html_encodeelgg_can_edit_widget_layout()now requires astringfor$contextandintfor$user_guidelgg_clear_event_handlers()now requires astringfor$eventand$typeelgg_clear_sticky_form()now requires astringfor$contextelgg_create_widget()now requires anintfor$owner_guidand$access_idand astringfor$handlerand$contextelgg_define_js()now requires astringfor$nameand anarrayfor$configelgg_delete_system_cache()now requires astringfor$typeelgg_echo()now requires astringfor$message_keyand astringfor$languageelgg_enqueue_notification_event()no longer requires a$typeelgg_entity_exists()now requires aintfor$guidelgg_entity_gatekeeper()now requires aintfor$guidand astringfor$typeand astringfor$subtypeand aboolfor$validate_can_editelgg_error_response()now requires astringorarrayfor$messageand astringfor$forward_urlelgg_extend_view()now requires astringfor$viewand$view_extensionelgg_extract()now requires aboolfor$strictelgg_format_bytes()now requires anintfor$sizeand$precisionelgg_format_element()now requires astringfor$tag_nameand astringfor$textelgg_format_html()now requires astringfor$htmlelgg_generate_action_url()now requires astringfor$actionand a boolean for$add_csrf_tokenselgg_generate_entity_url()now requires astringfor$resourceand$subresourceelgg_generate_url()now requires astringfor$nameelgg_get_config()now requires astringfor$nameelgg_get_download_url()now requires aboolfor$use_cookieand astringfor$expireselgg_get_embed_url()now requires astringfor$sizeelgg_get_entity_class()now requires astringfor$typeand astringfor$subtypeelgg_get_excerpt()now requires astringfor$textand anintfor$num_charselgg_get_friendly_upload_error()now requires anintfor$error_codeelgg_get_friendly_time()now requires anintfor$timeand$current_timeelgg_get_friendly_title()now requires astringfor$titleelgg_get_icon_sizes()now requires astringfor$entity_typeand$entity_subtypeelgg_get_ini_setting_in_bytes()now requires astringfor$settingelgg_get_inline_url()now requires aboolfor$use_cookieand astringfor$expireselgg_get_login_url()now requires astringfor$fragmentelgg_get_metadata_from_id()now requires anintfor$idelgg_get_registration_url()now requires astringfor$fragmentelgg_get_request_data()now requires aboolfor$filter_resultelgg_get_simplecache_url()now requires astringfor$viewand$sub_viewelgg_get_sticky_value()now requires astringfor$form_nameand a string for$variableand aboolfor$filter_resultelgg_get_sticky_values()now requires astringfor$form_nameand aboolfor$filter_resultelgg_get_title_input()now requires astringfor$variableand a string for$defaultelgg_get_uploaded_file()now requires astringfor$input_nameand aboolfor$check_for_validityelgg_get_uploaded_files()now requires astringfor$input_nameelgg_get_view_extensions()now requires astringfor$viewelgg_get_widget_types()now requires astringorarrayfor$contextelgg_get_widgets()now requires aintfor$owner_guidandstringfor$contextelgg_group_tool_gatekeeper()now requires astringfor$tool_nameand anintfor$group_guidelgg_html_decode()now requires astringfor$stringelgg_http_add_url_query_elements()now requires astringfor$urlelgg_http_build_url()now requires aboolfor$html_encodeelgg_http_get_signed_url()now requires astringfor$urland$expireselgg_http_remove_url_query_element()now requires astringfor$urland astringfor$elementelgg_http_url_is_identical()now requires astringfor$url1and$url2and anarrayfor$ignore_paramselgg_http_validate_signed_url()now requires astringfor$urlelgg_in_context()now requires astringfor$contextelgg_is_sticky_form()now requires astringfor$form_nameelgg_is_widget_type()now requires astringfor$handlerand$contextelgg_language_key_exists()now requires astringfor$keyand astringfor$languageelgg_list_entities()now requires acallablefor$getterand acallablefor$viewerelgg_list_entities_from_relationship_count()now requires anarrayfor$optionselgg_list_relationships()now requires anarrayfor$optionselgg_load_system_cache()now requires astringfor$typeelgg_make_sticky_form()now requires astringfor$form_nameelgg_normalize_site_url()now requires astringfor$unsafe_urlelgg_normalize_url()now requires astringfor$urlelgg_ok_response()now requires astringorarrayfor$messageand astringfor$forward_urlelgg_parse_emails()now requires astringfor$textelgg_push_context()now requires astringfor$contextelgg_redirect_response()now requires astringfor$forward_urlelgg_register_action()now requires astringfor$filenameelgg_register_ajax_view()now requires astringfor$viewelgg_register_error_message()now requires astring|arrayfor$messageelgg_register_event_handler()now requires astringfor$eventand$typeand anintfor$priorityand acallable|stringfor$callableelgg_register_menu_item()now requires astringfor$menu_nameand aarray|\ElggMenuItemfor$menu_itemelgg_register_notification_event()now requires astringfor$object_typeand$object_subtypeelgg_register_notification_method()now requires astringfor$nameelgg_register_route()now requires astringfor$nameelgg_register_simplecache_view()now requires astringfor$view_nameelgg_register_success_message()now requires astring|arrayfor$messageelgg_register_title_button()has the first argument ($handler) removed and requires astringfor$name,$entity_typeand$entity_subtypeelgg_register_viewtype_fallback()now requires astringfor$viewtypeelgg_register_widget_type()now only supports anarraysuitable for\Elgg\WidgetDefinition::factory()for$optionselgg_remove_config()now requires astringfor$nameelgg_require_js()now requires astringfor$nameelgg_save_config()now requires astringfor$nameelgg_save_resized_image()now requires astringfor$sourceand astringfor$destinationelgg_save_system_cache()now requires astringfor$typeelgg_set_config()now requires astringfor$nameelgg_set_context()now requires astringfor$contextelgg_set_entity_class()now requires astringfor$typeand astringfor$subtypeand astringfor$classelgg_set_form_footer()now requires astringfor$footerelgg_set_http_header()now requires astringfor$headerand aboolfor$replaceelgg_set_page_owner_guid()now requires aintfor$guidelgg_set_view_location()now requires astringfor$view,$locationand$viewtypeelgg_set_viewtype()now requires astringfor$viewtypeelgg_strip_tags()now requires astringfor$stringand$allowable_tagselgg_trigger_after_event()now requires astringfor$eventand$typeelgg_trigger_before_event()now requires astringfor$eventand$typeelgg_trigger_deprecated_event()now requires astringfor$event,$type,$messageand$versionelgg_trigger_event()now requires astringfor$eventand$typeelgg_unregister_ajax_view()now requires astringfor$viewelgg_register_event_handler()now requires astringfor$eventand$typeand acallable|stringfor$callableelgg_unregister_menu_item()now requires astringfor$menu_nameand$item_nameelgg_unregister_notification_event()now requires astringfor$object_typeand$object_subtypeelgg_unregister_notification_method()now requires astringfor$nameelgg_unregister_route()now requires astringfor$nameelgg_unregister_widget_type()now requires astringfor$handlerelgg_unrequire_js()now requires astringfor$nameelgg_validate_invite_code()now requires astringfor$usernameand$codeelgg_validate_registration_data()now requires astringfor$username,$nameand$email, aboolfor$multipleand astring|arrayfor$passwordelgg_view()now requires astringfor$viewand$viewtypeand aboolfor$recurseelgg_view_annotation_list()now requires anarrayfor$annotationselgg_view_deprecated()now requires astringfor$view,$messageand$versionelgg_view_comments()now requires anElggEntityfor$entityand aboolfor$add_commentelgg_view_entity_icon()now requires astringfor$sizeand anarrayfor$varselgg_view_entity_list()now requires anarrayfor$entitieselgg_view_exists()now requires astringfor$viewand$viewtypeand anarrayfor$varselgg_view_form()now requires astringfor$actionand anarrayfor$form_varsand$body_varselgg_view_icon()now requires astringfor$nameand anarrayfor$varselgg_view_image_block()now requires astringfor$type,$titleand$bodyelgg_view_layout()now requires astringfor$layout_nameand anarrayfor$varselgg_view_message()now requires astringfor$typeand$bodyelgg_view_page()now requires astringfor$titleand$page_shell, anarrayfor$varsand astring|arrayfor$bodyelgg_view_relationship_list()now requires anarrayfor$relationshipselgg_view_river_item()now requires anElggRiverItemfor$itemelgg_view_resource()now requires astringfor$nameelgg_view_title()now requires astringfor$titleembed_get_list_options()now requires anarrayfor$optionsembed_list_items()now requires anarrayfor$entitiesand$varsfile_prepare_form_vars()now requires anElggFilefor$fileget_entity()now requires aintfor$guidget_input()now requires astringfor$variableand aboolfor$filter_resultget_user()now requires aintfor$guidgroups_get_group_join_menu_item()now requires anElggUserfor$usergroups_get_group_leave_menu_item()now requires anElggUserfor$usergroups_get_invited_groups()now requires anintfor$user_guid, aboolfor$return_guidsand anarrayfor$optionsnotify_user()now requires anint|arrayfor$toand aintfor$fromand astringfor$subjectand$messagepages_get_navigation_tree()now requires aElggEntityfor$containerpages_prepare_form_vars()now requires aElggPagefor$page, anintfor$parent_guidand aElggAnnotationfor$revisionpages_prepare_parent_breadcrumbs()now requires aElggPagefor$pageset_input()now requires astringfor$variablethewire_filter()now requires astringfor$textthewire_get_hashtags()now requires astringfor$textthewire_save_post()now requires astringfor$textand$methodand anintfor$useridand$access_idand$parent_guiduservalidationbyemail_request_validation()now requires anintfor$user_guidelgg_ws_expose_function()now requires astringfor$methodand$descriptionand$call_method, anarrayfor$parametersand aboolfor$require_api_authand$require_user_authand$assocelgg_ws_register_service_handler()now requires astringfor$handlerelgg_ws_unexpose_function()now requires astringfor$methodand astringfor$http_request_methodelgg_ws_unregister_service_handler()now requires astringfor$handler
Class function return types
\ElggEntity::deleteMetadata()no longer returnsnull\ElggEntity::getOwnedAccessCollection()no longer returnsfalsebutnullwhen no access collection is found\ElggEntity::setContainerGUID()no longer returnsint\ElggFile::getDownloadURL()now returnsnullif there is an error\ElggFile::getInlineURL()now returnsnullif there is an error\ElggMenuItem::factory()no longer returnsnullif there is an error\Elgg\Page::getParentEntity()no longer returnsfalsebutnullif there is no parent entity found
Class function parameters
\ElggAccessCollection::getObjectFromID()now requires aintfor$id\ElggAnnotation::getObjectFromID()now requires aintfor$id\ElggEntity::addRelationship()now requires anintfor$guid_twoand astringfor$relationship\ElggEntity::cache()now requires aboolfor$persist\ElggEntity::canAnnotate()now requires anintfor$user_guidand astringfor$annotation_name\ElggEntity::canComment()now requires anintfor$user_guid\ElggEntity::canDelete()now requires anintfor$user_guid\ElggEntity::canEdit()now requires anintfor$user_guid\ElggEntity::canWriteToContainer()now requires anintfor$user_guidand astringfor$typeand$subtype\ElggEntity::countAnnotations()now requires astringfor$name\ElggEntity::countEntitiesFromRelationship()now requires astringfor$relationshipand aboolfor$inverse_relationship\ElggEntity::delete()now requires aboolfor$recursive\ElggEntity::deleteAnnotations()now requires astringfor$name\ElggEntity::deleteIcon()now requires astringfor$type\ElggEntity::deleteMetadata()now requires astringfor$name\ElggEntity::deleteOwnedAnnotations()now requires astringfor$name\ElggEntity::disable()now requires astringfor$reasonand aboolfor$recursive\ElggEntity::disableAnnotations()now requires astringfor$name\ElggEntity::enable()now requires aboolfor$recursive\ElggEntity::enableAnnotations()now requires astringfor$name\ElggEntity::getAnnotationsAvg()now requires astringfor$name\ElggEntity::getAnnotationsMax()now requires astringfor$name\ElggEntity::getAnnotationsSum()now requires astringfor$name\ElggEntity::getIcon()now requires astringfor$sizeand$type\ElggEntity::getIconLastChange()now requires astringfor$sizeand$type\ElggEntity::getIconURL()now requires astringorarrayfor$params\ElggEntity::getObjectFromID()now requires anintfor$id\ElggEntity::getOwnedAccessCollections()now requires anarrayfor$options\ElggEntity::getOwnedAccessCollection()now requires astringfor$subtype\ElggEntity::getMetadata()now requires astringfor$name\ElggEntity::getVolatileData()now requires astringfor$name\ElggEntity::hasIcon()now requires astringfor$sizeand$type\ElggEntity::removeAllRelationships()no longer allowsnullto be passed to$relationship\ElggEntity::removeRelationship()now requires anintfor$guid_twoand astringfor$relationship\ElggEntity::saveIconFromElggFile()now requires astringfor$type\ElggEntity::saveIconFromLocalFile()now requires astringfor$input_nameand$type\ElggEntity::saveIconFromUploadedFile()now requires astringfor$input_nameand$type\ElggEntity::setContainerGUID()now requires anintfor$container_guid\ElggEntity::setDisplayName()now requires astringfor$display_name\ElggEntity::setMetadata()now requires astringfor$nameand$value_typeand aboolfor$multiple\ElggEntity::setTempMetadata()now requires astringfor$nameand aboolfor$multiple\ElggEntity::setVolatileData()now requires astringfor$name\ElggEntity::updateLastAction()now requires anintfor$posted\ElggMetadata::getObjectFromID()now requires aintfor$id\ElggRelationship::getObjectFromID()now requires aintfor$id\ElggFile::getDownloadURL()now requires aboolfor$use_cookieand astringfor$expires\ElggFile::getInlineURL()now requires aboolfor$use_cookieand astringfor$expires\ElggGroup::isToolEnabled()now requires astringfor$name\ElggMenuItem::factory()now requires anarrayfor$options\ElggTempFile::getDownloadURL()now requires aboolfor$use_cookieand astringfor$expires\ElggTempFile::getInlineURL()now requires aboolfor$use_cookieand astringfor$expires\Elgg\WebServices\Di\ApiRegistrationService::registerApiMethod()now requires a\Elgg\WebServices\ApiMethodas the only parameter
Moved classes
\ElggAutoPhas been moved to\Elgg\Views\AutoParagraph\ElggCachehas been moved to\Elgg\Cache\BaseCache\ElggDiskFilestorehas been moved to\Elgg\Filesystem\Filestore\DiskFilestore\ElggFilestorehas been moved to\Elgg\Filesystem\Filestore\ElggRewriteTesterhas been moved to\Elgg\Router\RewriteTester\ElggTempDiskFilestorehas been moved to\Elgg\Filesystem\Filestore\TempDiskFilestore\Elgg\Database\SiteSecrethas been moved to\Elgg\Security\SiteSecret
Deprecated APIs
elgg_clear_plugin_hook_handlersuseelgg_clear_event_handlerselgg_register_plugin_hook_handleruseelgg_register_event_handlerelgg_trigger_plugin_hookuseelgg_trigger_event_resultselgg_unregister_plugin_hook_handleruseelgg_unregister_event_handlerget_user_by_emailuseelgg_get_user_by_emailget_user_by_usernameuseelgg_get_user_by_username
Removed classes
Elgg\WebServices\ApiKeyFormLoggablethis interface has been merged into theElggDataclass
Removed functions
blog_prepare_form_varsbookmarks_prepare_form_varsdiscussion_prepare_form_varselgg_get_breadcrumbselgg_pop_breadcrumbelgg_set_email_transportuse_elgg_services()->set('mailer', ...)elgg_trigger_deprecated_plugin_hookelgg_ws_expose_functionuseelgg-plugin.phpor'register', 'api_methods'eventfile_prepare_form_varsget_user_by_emailuseelgg_get_user_by_emailget_user_by_usernameuseelgg_get_user_by_usernamegroups_prepare_form_varsmessages_prepare_form_varspages_prepare_form_varsthewire_latest_guid
Removed class functions
\ElggWidget::saveSettings()
Removed events
access:collections:addcollection, collectionuse thecreate, access_collectionsequenceaccess:collections:deletecollection, collectionuse thedelete, access_collectionsequenceprepare, breadcrumbsuseregister, menu:breadcrumbswidget_settings, <widget_handler>
Removed exceptions
\Elgg\Exceptions\InvalidParameterException
Constants
The misspelled
REFERERconstant has been removed. UseREFERRERinstead.The
REFERRERconstant has been changed to a string with the value__elgg_referrer