We have moved to Github. Please open tickets there.

Opened 15 months ago

Last modified 12 months ago

#4378 new Defect

logic error in elgg_load_library

Reported by: coldtrick Owned by:
Priority: normal Milestone: Elgg 1.8.x
Component: Core Version: 1.8.3
Severity: minor Keywords:
Cc: brett@… Difficulty:

Description (last modified by ewinslow)

The function elgg_load_library should load a single library just once.

This is only the case if the path to a library is the same, which is not always the case. This could cause duplicate loads of the same library file and therefore cause fatal redeclaration errors.

The following is a real life situation of the above issue.


Having the HTMLawed plugin enabled i would like to have my own plugin provide a newer version of the htmlawed library. Therefore in the init of my plugin i would register a library.

elgg_register_library("htmlawed", $path_to_my_plugin_library);

If between the load of the htmlawed plugin and my plugin a get_input is triggered (this could certainly happen) that would have loaded the library registered in the html_lawed plugin (because of the filter tags hook). If after my plugin a new get_input is executed this will again try to load the htmlawed library (in the filter tags hook). As now my path to the library is registered for the htmlawed library it will be included again. That cause a redeclaration and thus an error.


This needs fixing.

Or we do not allow an override of an already registered library or we register if it is already loaded and won't load it again.

Change History (2)

comment:1 Changed 15 months ago by coldtrick

A more simple description of reproducing the problem is:

elgg_register_library("htmlawed", $path1);
elgg_load_library("htmlawed");
elgg_register_library("htmlawed", $path2);
elgg_load_library("htmlawed");

This can also be solved when everyone registers their library before loading them, for example in the start file (not in init). But still the situation should than be prevented as it could cause fatal errors.

comment:2 Changed 12 months ago by ewinslow

  • Description modified (diff)
  • Milestone changed from Needs Review to Elgg 1.8.x
Note: See TracTickets for help on using tickets.