Fatal errors after upgrading to 1.8.6: Revision

Last updated by Steve Clay

Problem

PHP type hints allow functions to demand what type of arguments are passed in. Before Elgg 1.8.6, violations of type hints went completely undetected, so many plugins may contain them.

1.8.6 prematurely escalated these errors to be fatal. You can recognize these in error logs by messages like:
"Argument <number> passed to <function>() must be <type>, <other_type> given".

Solution

Elgg 1.8.7 will downgrade these errors to warnings, but in the meantime, you may either fix your plugins, or apply this simple patch.

How to fix a plugin

The most common error is when authors assume get_entity() will return an ElggEntity (in many cases this returns false), then pass this value into a function that requires an entity, such as elgg_view_entity_icon().

Instead, plugins must test the return value of get_entity() before proceeding to treat it as an ElggEntity:

$entity = get_entity($guid);
if ($entity) {
    // use $entity as an ElggEntity
}

History