Migrating Omeka to PHP7 and MYSQL 5.7.16

Hello,
Due to some server update, I had to migrate Omeka (2.2.2) from PHP5 (5.3.10) to PHP7 (7.0.8) and from MYSQL 5.5.28 to MYSQL 5.7.16 .

I would like to share the results of my experience, some caveats to bear in mind that might be helpful to others.
I doesn’t work right away.
But it can be done.

3 things have to be considered :
A) Make sure your PHP has DOM EXTENSION installed and working
B) If using Omeka 2.2.2, comment break in getid3.lib.php
C) With MYSQL 5.7+ , default date cannot be “0000-00-00 00:00:00”

Now some details and explanations. I am as thorough as I can, but obviously I may have missed some things.


A) MAKE SHURE YOUR PHP HAS DOM EXTENSION INSTALLED AND WORKING
http://omeka.org/codex/Preparing_to_Install states that MYSQLI and EXIF extensions have to be installed ; Omeka also needs DOM extension to be installed, and it wasn’t on my PHP7.
Without DOM extension installed, I could not upload files, and noticed some weird behavior, like not being able to show elements sorted by title.

So, apache’s error.log states (/var/log/apache2/error.log)
PHP Fatal error: Uncaught Error: Class ‘DOMDocument’ not found in …

To install DOM extension:
sudo apt-get install php-xml


B) IF USING OMEKA 2.2.2, COMMENT BREAK IN GETID3.LIB.PHP
PHP 7 does not allow for ‘break’ not in the ‘loop’ or ‘switch’ context.

apache’s error.log (/var/log/apache2/error.log) states something like this:
PHP Fatal error: ‘break’ not in the ‘loop’ or ‘switch’ context in /var/www/standard/application/libraries/getid3/getid3.lib.php on line 285, referer: http://www.example.com/standard/admin/items/edit/1

I just edited file getid3.lib.php (/var/www/standard/application/libraries/getid3/getid3.lib.php) and commented the break in line 285
//break;

If this is not corrected, I get a white screen with no warning and no information when trying to upload a file. Once corrected, it looks like everything is fine, at least did not find any other trouble.

Note that Omeka 2.4.1 has this corrected!


C) With MYSQL 5.7+ , default date cannot be "0000-00-00 00:00:00"
This is only with MYSQL 5.7 or higher, and apparently, only when trying to make a new install of Omeka.
[I did not had troubles with databases restored from dump]
When installing, Omeka says:
Schema task failed on table ‘omeka_collections’ with Zend_Db_Statement_Mysqli_Exception: Mysqli statement execute error : Invalid default value for ‘added’

This is already documented in the following, so I am not repeating it (just go and check):

You will have to change the default dates on a few MySQL tables:
collections.sql (fields "added", "modified"), 
files.sql (fields "added"), 
items.sql (fields "added"), 
processes.sql (fields "added", "modified")	

Hope this helps.

1 Like