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_array
elgg.is_instant_hook
elgg.is_triggered_hook
elgg.push_to_object_array
elgg.register_hook_handler
use theregister
function provide by theelgg\hooks
moduleelgg.register_instant_hook
elgg.set_triggered_hook
elgg.trigger_hook
use thetrigger
function provided by theelgg\hooks
module
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 returnsnull
on failure instead of abool
elgg_create_river_item()
now returnsnull
on failure or anElggRiverItem
elgg_delete_metadata()
no longer returnsnull
elgg_delete_river()
no longer returnsnull
elgg_deprecated_notice()
no longer returnsbool
elgg_generate_entity_url()
now returnsnull
on failure instead of abool
elgg_generate_url()
now returnsnull
on failure instead of abool
elgg_get_annotation_from_id()
now returnsnull
if no annotation is found instead of abool
elgg_get_download_url()
now returnsnull
if there is an errorelgg_get_entity_as_row()
now returnsnull
if no entity is found instead of abool
elgg_get_entity_dates()
no longer returns abool
elgg_get_form_footer()
no longer returns abool
elgg_get_inline_url()
now returnsnull
if there is an errorelgg_get_metadata_from_id()
now returnsnull
if no metadata could be foundelgg_get_page_owner_entity()
now returnsnull
if page owner could not be foundelgg_get_river_item_from_id()
now returnsnull
if no river item could be foundelgg_get_system_cache()
now returns an instance of\Elgg\Cache\BaseCache
instead of an\ElggCache
elgg_get_uploaded_file()
now returnsnull
if no file could be found or the file was invalidelgg_normalize_site_url()
now returnsnull
when the url is not a site urlelgg_register_action()
no longer returns abool
elgg_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 abool
elgg_view_comments()
no longer returns abool
elgg_view_list_item()
no longer returns abool
elgg_view_relationship()
no longer returns abool
get_entity()
now returnsnull
if no entity is found instead of abool
get_user()
now returnsnull
if no user is found instead of abool
elgg_ws_expose_function()
no longer returns abool
Lib functions function parameters
blog_prepare_form_vars()
now requires aElggBlog
for$blog
and aElggAnnotation
for$revision
bookmarks_prepare_form_vars()
now requires aElggBookmark
for$bookmark
discussion_prepare_form_vars()
now requires aElggDiscussion
for$topic
elgg_add_action_tokens_to_url()
now requires astring
for$url
and abool
for$html_encode
elgg_can_edit_widget_layout()
now requires astring
for$context
andint
for$user_guid
elgg_clear_event_handlers()
now requires astring
for$event
and$type
elgg_clear_sticky_form()
now requires astring
for$context
elgg_create_widget()
now requires anint
for$owner_guid
and$access_id
and astring
for$handler
and$context
elgg_define_js()
now requires astring
for$name
and anarray
for$config
elgg_delete_system_cache()
now requires astring
for$type
elgg_echo()
now requires astring
for$message_key
and astring
for$language
elgg_enqueue_notification_event()
no longer requires a$type
elgg_entity_exists()
now requires aint
for$guid
elgg_entity_gatekeeper()
now requires aint
for$guid
and astring
for$type
and astring
for$subtype
and abool
for$validate_can_edit
elgg_error_response()
now requires astring
orarray
for$message
and astring
for$forward_url
elgg_extend_view()
now requires astring
for$view
and$view_extension
elgg_extract()
now requires abool
for$strict
elgg_format_bytes()
now requires anint
for$size
and$precision
elgg_format_element()
now requires astring
for$tag_name
and astring
for$text
elgg_format_html()
now requires astring
for$html
elgg_generate_action_url()
now requires astring
for$action
and a boolean for$add_csrf_tokens
elgg_generate_entity_url()
now requires astring
for$resource
and$subresource
elgg_generate_url()
now requires astring
for$name
elgg_get_config()
now requires astring
for$name
elgg_get_download_url()
now requires abool
for$use_cookie
and astring
for$expires
elgg_get_embed_url()
now requires astring
for$size
elgg_get_entity_class()
now requires astring
for$type
and astring
for$subtype
elgg_get_excerpt()
now requires astring
for$text
and anint
for$num_chars
elgg_get_friendly_upload_error()
now requires anint
for$error_code
elgg_get_friendly_time()
now requires anint
for$time
and$current_time
elgg_get_friendly_title()
now requires astring
for$title
elgg_get_icon_sizes()
now requires astring
for$entity_type
and$entity_subtype
elgg_get_ini_setting_in_bytes()
now requires astring
for$setting
elgg_get_inline_url()
now requires abool
for$use_cookie
and astring
for$expires
elgg_get_login_url()
now requires astring
for$fragment
elgg_get_metadata_from_id()
now requires anint
for$id
elgg_get_registration_url()
now requires astring
for$fragment
elgg_get_request_data()
now requires abool
for$filter_result
elgg_get_simplecache_url()
now requires astring
for$view
and$sub_view
elgg_get_sticky_value()
now requires astring
for$form_name
and a string for$variable
and abool
for$filter_result
elgg_get_sticky_values()
now requires astring
for$form_name
and abool
for$filter_result
elgg_get_title_input()
now requires astring
for$variable
and a string for$default
elgg_get_uploaded_file()
now requires astring
for$input_name
and abool
for$check_for_validity
elgg_get_uploaded_files()
now requires astring
for$input_name
elgg_get_view_extensions()
now requires astring
for$view
elgg_get_widget_types()
now requires astring
orarray
for$context
elgg_get_widgets()
now requires aint
for$owner_guid
andstring
for$context
elgg_group_tool_gatekeeper()
now requires astring
for$tool_name
and anint
for$group_guid
elgg_html_decode()
now requires astring
for$string
elgg_http_add_url_query_elements()
now requires astring
for$url
elgg_http_build_url()
now requires abool
for$html_encode
elgg_http_get_signed_url()
now requires astring
for$url
and$expires
elgg_http_remove_url_query_element()
now requires astring
for$url
and astring
for$element
elgg_http_url_is_identical()
now requires astring
for$url1
and$url2
and anarray
for$ignore_params
elgg_http_validate_signed_url()
now requires astring
for$url
elgg_in_context()
now requires astring
for$context
elgg_is_sticky_form()
now requires astring
for$form_name
elgg_is_widget_type()
now requires astring
for$handler
and$context
elgg_language_key_exists()
now requires astring
for$key
and astring
for$language
elgg_list_entities()
now requires acallable
for$getter
and acallable
for$viewer
elgg_list_entities_from_relationship_count()
now requires anarray
for$options
elgg_list_relationships()
now requires anarray
for$options
elgg_load_system_cache()
now requires astring
for$type
elgg_make_sticky_form()
now requires astring
for$form_name
elgg_normalize_site_url()
now requires astring
for$unsafe_url
elgg_normalize_url()
now requires astring
for$url
elgg_ok_response()
now requires astring
orarray
for$message
and astring
for$forward_url
elgg_parse_emails()
now requires astring
for$text
elgg_push_context()
now requires astring
for$context
elgg_redirect_response()
now requires astring
for$forward_url
elgg_register_action()
now requires astring
for$filename
elgg_register_ajax_view()
now requires astring
for$view
elgg_register_error_message()
now requires astring|array
for$message
elgg_register_event_handler()
now requires astring
for$event
and$type
and anint
for$priority
and acallable|string
for$callable
elgg_register_menu_item()
now requires astring
for$menu_name
and aarray|\ElggMenuItem
for$menu_item
elgg_register_notification_event()
now requires astring
for$object_type
and$object_subtype
elgg_register_notification_method()
now requires astring
for$name
elgg_register_route()
now requires astring
for$name
elgg_register_simplecache_view()
now requires astring
for$view_name
elgg_register_success_message()
now requires astring|array
for$message
elgg_register_title_button()
has the first argument ($handler
) removed and requires astring
for$name
,$entity_type
and$entity_subtype
elgg_register_viewtype_fallback()
now requires astring
for$viewtype
elgg_register_widget_type()
now only supports anarray
suitable for\Elgg\WidgetDefinition::factory()
for$options
elgg_remove_config()
now requires astring
for$name
elgg_require_js()
now requires astring
for$name
elgg_save_config()
now requires astring
for$name
elgg_save_resized_image()
now requires astring
for$source
and astring
for$destination
elgg_save_system_cache()
now requires astring
for$type
elgg_set_config()
now requires astring
for$name
elgg_set_context()
now requires astring
for$context
elgg_set_entity_class()
now requires astring
for$type
and astring
for$subtype
and astring
for$class
elgg_set_form_footer()
now requires astring
for$footer
elgg_set_http_header()
now requires astring
for$header
and abool
for$replace
elgg_set_page_owner_guid()
now requires aint
for$guid
elgg_set_view_location()
now requires astring
for$view
,$location
and$viewtype
elgg_set_viewtype()
now requires astring
for$viewtype
elgg_strip_tags()
now requires astring
for$string
and$allowable_tags
elgg_trigger_after_event()
now requires astring
for$event
and$type
elgg_trigger_before_event()
now requires astring
for$event
and$type
elgg_trigger_deprecated_event()
now requires astring
for$event
,$type
,$message
and$version
elgg_trigger_event()
now requires astring
for$event
and$type
elgg_unregister_ajax_view()
now requires astring
for$view
elgg_register_event_handler()
now requires astring
for$event
and$type
and acallable|string
for$callable
elgg_unregister_menu_item()
now requires astring
for$menu_name
and$item_name
elgg_unregister_notification_event()
now requires astring
for$object_type
and$object_subtype
elgg_unregister_notification_method()
now requires astring
for$name
elgg_unregister_route()
now requires astring
for$name
elgg_unregister_widget_type()
now requires astring
for$handler
elgg_unrequire_js()
now requires astring
for$name
elgg_validate_invite_code()
now requires astring
for$username
and$code
elgg_validate_registration_data()
now requires astring
for$username
,$name
and$email
, abool
for$multiple
and astring|array
for$password
elgg_view()
now requires astring
for$view
and$viewtype
and abool
for$recurse
elgg_view_annotation_list()
now requires anarray
for$annotations
elgg_view_deprecated()
now requires astring
for$view
,$message
and$version
elgg_view_comments()
now requires anElggEntity
for$entity
and abool
for$add_comment
elgg_view_entity_icon()
now requires astring
for$size
and anarray
for$vars
elgg_view_entity_list()
now requires anarray
for$entities
elgg_view_exists()
now requires astring
for$view
and$viewtype
and anarray
for$vars
elgg_view_form()
now requires astring
for$action
and anarray
for$form_vars
and$body_vars
elgg_view_icon()
now requires astring
for$name
and anarray
for$vars
elgg_view_image_block()
now requires astring
for$type
,$title
and$body
elgg_view_layout()
now requires astring
for$layout_name
and anarray
for$vars
elgg_view_message()
now requires astring
for$type
and$body
elgg_view_page()
now requires astring
for$title
and$page_shell
, anarray
for$vars
and astring|array
for$body
elgg_view_relationship_list()
now requires anarray
for$relationships
elgg_view_river_item()
now requires anElggRiverItem
for$item
elgg_view_resource()
now requires astring
for$name
elgg_view_title()
now requires astring
for$title
embed_get_list_options()
now requires anarray
for$options
embed_list_items()
now requires anarray
for$entities
and$vars
file_prepare_form_vars()
now requires anElggFile
for$file
get_entity()
now requires aint
for$guid
get_input()
now requires astring
for$variable
and abool
for$filter_result
get_user()
now requires aint
for$guid
groups_get_group_join_menu_item()
now requires anElggUser
for$user
groups_get_group_leave_menu_item()
now requires anElggUser
for$user
groups_get_invited_groups()
now requires anint
for$user_guid
, abool
for$return_guids
and anarray
for$options
notify_user()
now requires anint|array
for$to
and aint
for$from
and astring
for$subject
and$message
pages_get_navigation_tree()
now requires aElggEntity
for$container
pages_prepare_form_vars()
now requires aElggPage
for$page
, anint
for$parent_guid
and aElggAnnotation
for$revision
pages_prepare_parent_breadcrumbs()
now requires aElggPage
for$page
set_input()
now requires astring
for$variable
thewire_filter()
now requires astring
for$text
thewire_get_hashtags()
now requires astring
for$text
thewire_save_post()
now requires astring
for$text
and$method
and anint
for$userid
and$access_id
and$parent_guid
uservalidationbyemail_request_validation()
now requires anint
for$user_guid
elgg_ws_expose_function()
now requires astring
for$method
and$description
and$call_method
, anarray
for$parameters
and abool
for$require_api_auth
and$require_user_auth
and$assoc
elgg_ws_register_service_handler()
now requires astring
for$handler
elgg_ws_unexpose_function()
now requires astring
for$method
and astring
for$http_request_method
elgg_ws_unregister_service_handler()
now requires astring
for$handler
Class function return types
\ElggEntity::deleteMetadata()
no longer returnsnull
\ElggEntity::getOwnedAccessCollection()
no longer returnsfalse
butnull
when no access collection is found\ElggEntity::setContainerGUID()
no longer returnsint
\ElggFile::getDownloadURL()
now returnsnull
if there is an error\ElggFile::getInlineURL()
now returnsnull
if there is an error\ElggMenuItem::factory()
no longer returnsnull
if there is an error\Elgg\Page::getParentEntity()
no longer returnsfalse
butnull
if there is no parent entity found
Class function parameters
\ElggAccessCollection::getObjectFromID()
now requires aint
for$id
\ElggAnnotation::getObjectFromID()
now requires aint
for$id
\ElggEntity::addRelationship()
now requires anint
for$guid_two
and astring
for$relationship
\ElggEntity::cache()
now requires abool
for$persist
\ElggEntity::canAnnotate()
now requires anint
for$user_guid
and astring
for$annotation_name
\ElggEntity::canComment()
now requires anint
for$user_guid
\ElggEntity::canDelete()
now requires anint
for$user_guid
\ElggEntity::canEdit()
now requires anint
for$user_guid
\ElggEntity::canWriteToContainer()
now requires anint
for$user_guid
and astring
for$type
and$subtype
\ElggEntity::countAnnotations()
now requires astring
for$name
\ElggEntity::countEntitiesFromRelationship()
now requires astring
for$relationship
and abool
for$inverse_relationship
\ElggEntity::delete()
now requires abool
for$recursive
\ElggEntity::deleteAnnotations()
now requires astring
for$name
\ElggEntity::deleteIcon()
now requires astring
for$type
\ElggEntity::deleteMetadata()
now requires astring
for$name
\ElggEntity::deleteOwnedAnnotations()
now requires astring
for$name
\ElggEntity::disable()
now requires astring
for$reason
and abool
for$recursive
\ElggEntity::disableAnnotations()
now requires astring
for$name
\ElggEntity::enable()
now requires abool
for$recursive
\ElggEntity::enableAnnotations()
now requires astring
for$name
\ElggEntity::getAnnotationsAvg()
now requires astring
for$name
\ElggEntity::getAnnotationsMax()
now requires astring
for$name
\ElggEntity::getAnnotationsSum()
now requires astring
for$name
\ElggEntity::getIcon()
now requires astring
for$size
and$type
\ElggEntity::getIconLastChange()
now requires astring
for$size
and$type
\ElggEntity::getIconURL()
now requires astring
orarray
for$params
\ElggEntity::getObjectFromID()
now requires anint
for$id
\ElggEntity::getOwnedAccessCollections()
now requires anarray
for$options
\ElggEntity::getOwnedAccessCollection()
now requires astring
for$subtype
\ElggEntity::getMetadata()
now requires astring
for$name
\ElggEntity::getVolatileData()
now requires astring
for$name
\ElggEntity::hasIcon()
now requires astring
for$size
and$type
\ElggEntity::removeAllRelationships()
no longer allowsnull
to be passed to$relationship
\ElggEntity::removeRelationship()
now requires anint
for$guid_two
and astring
for$relationship
\ElggEntity::saveIconFromElggFile()
now requires astring
for$type
\ElggEntity::saveIconFromLocalFile()
now requires astring
for$input_name
and$type
\ElggEntity::saveIconFromUploadedFile()
now requires astring
for$input_name
and$type
\ElggEntity::setContainerGUID()
now requires anint
for$container_guid
\ElggEntity::setDisplayName()
now requires astring
for$display_name
\ElggEntity::setMetadata()
now requires astring
for$name
and$value_type
and abool
for$multiple
\ElggEntity::setTempMetadata()
now requires astring
for$name
and abool
for$multiple
\ElggEntity::setVolatileData()
now requires astring
for$name
\ElggEntity::updateLastAction()
now requires anint
for$posted
\ElggMetadata::getObjectFromID()
now requires aint
for$id
\ElggRelationship::getObjectFromID()
now requires aint
for$id
\ElggFile::getDownloadURL()
now requires abool
for$use_cookie
and astring
for$expires
\ElggFile::getInlineURL()
now requires abool
for$use_cookie
and astring
for$expires
\ElggGroup::isToolEnabled()
now requires astring
for$name
\ElggMenuItem::factory()
now requires anarray
for$options
\ElggTempFile::getDownloadURL()
now requires abool
for$use_cookie
and astring
for$expires
\ElggTempFile::getInlineURL()
now requires abool
for$use_cookie
and astring
for$expires
\Elgg\WebServices\Di\ApiRegistrationService::registerApiMethod()
now requires a\Elgg\WebServices\ApiMethod
as the only parameter
Moved classes
\ElggAutoP
has been moved to\Elgg\Views\AutoParagraph
\ElggCache
has been moved to\Elgg\Cache\BaseCache
\ElggDiskFilestore
has been moved to\Elgg\Filesystem\Filestore\DiskFilestore
\ElggFilestore
has been moved to\Elgg\Filesystem\Filestore
\ElggRewriteTester
has been moved to\Elgg\Router\RewriteTester
\ElggTempDiskFilestore
has been moved to\Elgg\Filesystem\Filestore\TempDiskFilestore
\Elgg\Database\SiteSecret
has been moved to\Elgg\Security\SiteSecret
Deprecated APIs
elgg_clear_plugin_hook_handlers
useelgg_clear_event_handlers
elgg_register_plugin_hook_handler
useelgg_register_event_handler
elgg_trigger_plugin_hook
useelgg_trigger_event_results
elgg_unregister_plugin_hook_handler
useelgg_unregister_event_handler
get_user_by_email
useelgg_get_user_by_email
get_user_by_username
useelgg_get_user_by_username
Removed classes
Elgg\WebServices\ApiKeyForm
Loggable
this interface has been merged into theElggData
class
Removed functions
blog_prepare_form_vars
bookmarks_prepare_form_vars
discussion_prepare_form_vars
elgg_get_breadcrumbs
elgg_pop_breadcrumb
elgg_set_email_transport
use_elgg_services()->set('mailer', ...)
elgg_trigger_deprecated_plugin_hook
elgg_ws_expose_function
useelgg-plugin.php
or'register', 'api_methods'
eventfile_prepare_form_vars
get_user_by_email
useelgg_get_user_by_email
get_user_by_username
useelgg_get_user_by_username
groups_prepare_form_vars
messages_prepare_form_vars
pages_prepare_form_vars
thewire_latest_guid
Removed class functions
\ElggWidget::saveSettings()
Removed events
access:collections:addcollection, collection
use thecreate, access_collection
sequenceaccess:collections:deletecollection, collection
use thedelete, access_collection
sequenceprepare, breadcrumbs
useregister, menu:breadcrumbs
widget_settings, <widget_handler>
Removed exceptions
\Elgg\Exceptions\InvalidParameterException
Constants
The misspelled
REFERER
constant has been removed. UseREFERRER
instead.The
REFERRER
constant has been changed to a string with the value__elgg_referrer