Depreciated: array_key_exists()

In moving our archive to a new Ubuntu server our service provider encountered this error:

Deprecated: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in /home/pateam/public_html/application/libraries/Zend/Registry.php on line 206

This looks like a simple error BUT
/home/pateam/public_html/application/libraries/Zend/Registry.php is not a valid path. We changed line 206 in /home/pateam/public_html/Omeka/application/libraries/Zend/Registry.php and the website continues to throw the same error.

A search of the directory found 4 instances of Registry.php. We could search out and change all 4 but that may not be the end of it. A google search for the error found this explanation:
[Begin Quote]
array_key_exists() is NOT deprecated, the deprecation is using the function with objects (i.e. something like Joomla\Registry\Registry which implements ArrayAccess meaning you can work with the registry object as an array).

$thing = new Joomla\Registry\Registry;
$thing[‘foo’] = true;
$thing[‘bar’] = true;

array_key_exists(‘foo’, $thing); // emits deprecation because an object is being checked

$otherThing = array();
$otherThing[‘foo’] = true;
$otherThing[‘bar’] = true;
[End quote]

So array_key_exists may be searching for something it can’t find and throwing this misleading error message.

The new machine runs php 7.4. the old ran php 7.2

What version of Omeka are you using?

We are running 2.1.3 on the active site.

The deprecation of array_key_exists that you’re talking about here occurred in PHP 7.4, released in 2019.

Omeka 2.1.3 is from 2013. The latest version of Omeka Classic, 2.7.1, makes changes to eliminate those deprecation warnings under PHP 7.4.

It’s possible to make changes to an older version to eliminate those warnings, but I can’t really recommend that an active site stay on such an old version.

We have the same problem. Our site was working fine and now it looks like this:!

The same advice applies: this is happening because your server has updated to a newer version of PHP. Omeka’s newer versions made changes to support those newer PHP versions without throwing these warnings, so updating Omeka to the latest version would make them go away.

They’re deprecation warnings rather than errors, so simply turning off error display in the .htaccess file would stop them being visible. My general advice would be to upgrade, particularly if you’re already on a relatively recent version of Omeka.