<commit_before><?php

if (!isset($_SERVER['MIDGARD_ENV_GLOBAL_SHAREDIR']))
    throw new Exception('MIDGARD_ENV_GLOBAL_SHAREDIR environment variable is not set');

if (!isset($_SERVER['PAKE_MIDGARD_CFG']))
    throw new Exception('PAKE_MIDGARD_CFG environment variable is not set');

if (extension_loaded('midgard2')) {
    throw new LogicException('Please disable midgard2-extension in php.ini. test-suite will enable it automatically');
}

if (ini_get('enable_dl') != 1) {
    throw new LogicException('Please enable "enable_dl" setting in php.ini. it is required for proper work of tests');
}

ini_set('midgard.http', 'Off');

$cfg = new midgard_config();
$cfg->read_file_at_path($_SERVER['PAKE_MIDGARD_CFG']);
$cfg->create_blobdir();

$mgd = midgard_connection::get_instance();
$res = $mgd->open_config($cfg);

if (false === $res) {<commit_msg>Throw exception if extension is not loaded<commit_after><?php

if (!isset($_SERVER['MIDGARD_ENV_GLOBAL_SHAREDIR']))
    throw new Exception('MIDGARD_ENV_GLOBAL_SHAREDIR environment variable is not set');

if (!isset($_SERVER['PAKE_MIDGARD_CFG']))
    throw new Exception('PAKE_MIDGARD_CFG environment variable is not set');

if (!extension_loaded('midgard2')) {
    throw new LogicException('Please enable midgard2-extension in php.ini');
}

if (ini_get('enable_dl') != 1) {
    throw new LogicException('Please enable "enable_dl" setting in php.ini. it is required for proper work of tests');
}

ini_set('midgard.http', 'Off');

$cfg = new midgard_config();
$cfg->read_file_at_path($_SERVER['PAKE_MIDGARD_CFG']);
$cfg->create_blobdir();

$mgd = midgard_connection::get_instance();
$res = $mgd->open_config($cfg);

if (false === $res) {
{'fraction_non_alphanumeric': 0.14786223277909738, 'fraction_numerical': 0.0035629453681710215, 'mean_word_length': 6.59009009009009, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7357526', 'n_tokens_mistral': 577, 'n_tokens_neox': 566, 'n_words': 137}