Test the cache_advagg_info cache bin; make sure it works.

Return value

array Single section of the requirements array.

2 calls to advagg_js_compress_check_cache_bin()
advagg_js_compress_admin_settings_form dans advagg_js_compress/advagg_js_compress.admin.inc
Form builder; Configure advagg settings.
advagg_js_compress_requirements dans advagg_js_compress/advagg_js_compress.install
Implements hook_requirements().

Fichier

advagg_js_compress/advagg_js_compress.module, line 749

Code

function advagg_js_compress_check_cache_bin() {
    $t = get_t();
    $requirements = array();
    // Make sure cache table is working.
    $cid = 'advagg_js_compres:install:cache_test';
    $bin = 'cache_advagg_info';
    cache_set($cid, TRUE, $bin);
    $cache = cache_get($cid, $bin);
    $working = FALSE;
    if (!empty($cache->data)) {
        cache_clear_all($cid, $bin);
        $cache = cache_get($cid, $bin);
        if (empty($cache->data)) {
            $working = TRUE;
        }
    }
    if (empty($working)) {
        $broken_name = get_class(_cache_get_object($bin));
        if ($broken_name === 'DrupalFakeCache') {
            $working_name = get_class(_cache_get_object('cache_form'));
            if ($working_name === 'DrupalFakeCache') {
                $working_name = 'DrupalDatabaseCache';
            }
            $extra_description = t('Please add this to the bottom of your settings.php file. <p><code>@string</code></p>', array(
                '@string' => "\$conf['cache_class_cache_advagg_info'] = '{$working_name}';",
            ));
        }
        $requirements['advagg_js_compres_cache_bin'] = array(
            'title' => $t('AdvAgg JS Compressor - The %bin cache table does not work', array(
                '%bin' => $bin,
            )),
            'severity' => REQUIREMENT_WARNING,
            'value' => $t('The %class_name cache bin appears to be broken.', array(
                '%class_name' => $broken_name,
            )),
            'description' => $t('You need to adjust your settings.php file so that the %bin bin is working correctly.', array(
                '%bin' => $bin,
            )),
        );
        if (isset($extra_description)) {
            $requirements['advagg_js_compres_cache_bin']['description'] .= " {$extra_description}";
        }
    }
    return $requirements;
}