Omeka won't run after upgrading to PHP7

A few days ago we had to upgrade our web server from PHP 5.6 to PHP 7.1.2.
The main Drupal 7 site works fine, but I can’t get our Omeka installs to display anything. The error I get in the apache log file is:

[Mon Feb 27 05:03:38.800673 2017] [php7:error] [pid 23162] [client 216.244.66.241:45524] PHP Fatal error: Declaration of Omeka_Storage_Adapter_Filesystem::__construct(array $options = Array) must be compatible with Omeka_Storage_Adapter_AdapterInterface::__construct(?array $options = NULL) in /srv/http/episcopalarchives.org/html/jma-presiding-bishop/application/libraries/Omeka/Storage/Adapter/Filesystem.php on line 17

I tried googling for this error, but the google results just pertain to general PHP issues, and not Omeka in particular, and it’s not a general issue, since the other PHP content appears to be working.

Thanks in advance.

What version of Omeka do you have? It looks like the latest (2.5) addresses this.

Hi Patrick -

I upgraded Omeka this morning before posting, so it’s definitely the latest (2.5) version. What the evidence that 2.5 addresses this?

I saw the question mark in the error message Omeka_Storage_Adapter_AdapterInterface::construct(?array $options = NULL), but it’s not in the current file, so I hoped that was the cause.

Looking again, one file does say the default value for $options is an array in one place, and null in the other. We’ll have to check if how that difference is handled is a change in PHP 7.1. It doesn’t throw an error on my PHP 7.0 system, so there might be a difference in how PHP 7.1 enforces that kind of compatibility.

It’s an Arch system, so the PHP version is 7.1.2. We actually had to downgrade back to PHP 5.6.16 because Drupal 7, in particular the webforms module, was exhibiting extremely strange behavior. Right now I’m staying on this because the upgrade back to PHP 7 is inevitable in the somewhat near future.

On our end, it looks like it’s just this quick fix.

So, is this something I should just change myself in the AdapterInterface.php file, or will this fix be migrated in to the downloadable zip file relatively soon?

This will be in a 2.5.1 release, but can’t be sure when that will happen. You should probably just make that change yourself if you run Omeka on PHP 7.1

Making the suggested fix worked perfecly – thanks, Patrick!

We took our sweet time but the promised 2.5.1 release containing this fix officially is out.

1 Like