Run various theme functions so the cache is primed.

Paramètres

$files_to_test: array with md5 and filename.

Return value

TRUE if all files are compressible. List of files that failed otherwise.

3 calls to advagg_js_compress_test_compression()
advagg_js_compress_advagg_files_table dans advagg_js_compress/advagg_js_compress.module
Implements hook_advagg_files_table().
advagg_js_compress_check_callback dans advagg_js_compress/advagg_js_compress.install
Check to see if the CSS/JS generator is working.
advagg_js_compress_prep dans advagg_js_compress/advagg_js_compress.module
Compress a JS string

Fichier

advagg_js_compress/advagg_js_compress.module, line 317

Code

function advagg_js_compress_test_compression($files_to_test) {
    global $base_path;
    $bad_files = array();
    // Blacklist jquery.min.js from getting compressed.
    if (module_exists('jquery_update')) {
        foreach ($files_to_test as $key => $info) {
            if (strpos($info['filename'], 'jquery.min.js') !== FALSE) {
                // Add file to the bad list.
                $bad_files[] = $info;
                unset($files_to_test[$key]);
                // Get file data.
                $filename_md5 = md5($info['filename']);
                $lock_name = 'advagg_set_file_data_' . $filename_md5;
                if (!lock_acquire($lock_name, 10)) {
                    lock_wait($lock_name);
                    continue;
                }
                $data = advagg_get_file_data($filename_md5);
                // Set to -2
                if (!isset($data->data['advagg_js_compress']['tested']['jsminplus']) || $data->data['advagg_js_compress']['tested']['jsminplus'] != -2) {
                    $data['advagg_js_compress']['tested']['jsminplus'] = -2;
                    advagg_set_file_data($filename_md5, $data);
                }
                lock_release($lock_name);
            }
        }
    }
    foreach ($files_to_test as $info) {
        $key = variable_get('advagg_js_compress_url_key', FALSE);
        if (empty($key)) {
            $key = mt_rand();
            variable_set('advagg_js_compress_url_key', $key);
        }
        // Clear the cache for this file
        cache_clear_all($info['filename'], 'cache_advagg_js_compress_file');
        // Setup request URL and headers.
        $query['values'] = $info;
        $query['key'] = $key;
        $query_string = http_build_query($query, '', '&');
        $url = _advagg_build_url('advagg/js_compress_test_file');
        $headers = array(
            'Host' => $_SERVER['HTTP_HOST'],
            'Content-Type' => 'application/x-www-form-urlencoded',
            'Connection' => 'close',
        );
        $results = drupal_http_request($url, array(
            'headers' => $headers,
            'method' => 'POST',
            'data' => $query_string,
        ));
        // Get file data.
        $filename_md5 = md5($info['filename']);
        $data = advagg_get_file_data($filename_md5);
        // Mark as a bad file.
        if (empty($data['advagg_js_compress']['tested']['jsminplus']) || $data['advagg_js_compress']['tested']['jsminplus'] != 1) {
            $bad_files[] = $info;
        }
    }
    if (empty($bad_files)) {
        return TRUE;
    }
    return $bad_files;
}