1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 
<?php
namespace Omeka\Installation\Task;

use Omeka\Installation\Installer;

/**
 * Check database configuration task.
 */
class CheckDbConfigurationTask implements TaskInterface
{
    const MYSQL_MINIMUM_VERSION = '5.5.3';

    public function perform(Installer $installer)
    {
        try {
            $connection = $installer->getServiceLocator()->get('Omeka\Connection');
            $connection->connect();
        } catch (\Exception $e) {
            $installer->addError($e->getMessage());
            return;
        }

        $version = $connection->getWrappedConnection()->getServerVersion();
        if (version_compare($version, self::MYSQL_MINIMUM_VERSION, '<')) {
            $installer->addError(sprintf(
                'Omeka requires at least MySQL version %s, but this server is running version %s.',
                self::MYSQL_MINIMUM_VERSION, $version));
        }
    }
}