Fatal errors after upgrading to 1.8.6: Revision

Last updated by Steve Clay


Type hints are like laws set by PHP functions to demand what type of arguments must be passed in. Before Elgg 1.8.6, violations of these laws went completely undetected, so even careful plugin authors missed them and left incorrect code in their plugins.

The Elgg 1.8.6 release escalated these violations to fatal errors. You may recognize these in your server error logs by messages like:
"Argument number passed to function() must be type, other_type given".


The Elgg team realized the 1.8.6 change was premature, and Elgg 1.8.7 will downgrade these errors to warnings, but in the meantime, a site owner running 1.8.6 has a few options:

  1. Make a small change in a core file. This returns Elgg to ignoring type hint violations. When you upgrade to a later version, the patch will no longer be needed.
  2. Fix the type hint errors in your plugins

How to fix a plugin (for programmers)

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

Instead, authors must test the return value of get_entity() before treating the value as an ElggEntity:

$entity = get_entity($guid);
if ($entity) {
    // $entity is an ElggEntity
} else {
// $entity is false