You are here

function advagg_missing_file_not_readable in Advanced CSS/JS Aggregation 7.2

Let other modules know that this file couldn't be found.

Parameters

string $filename: Filename of the missing file.

string $aggregate_filename: Filename of the aggregate that is trying to be generated.

bool $fs_read_failure: Set to TRUE if the file system couldn't be read.

2 calls to advagg_missing_file_not_readable()
advagg_get_css_aggregate_contents in ./advagg.missing.inc
Given a list of files, grab their contents and glue it into one big string.
advagg_get_js_aggregate_contents in ./advagg.missing.inc
Given a list of files, grab their contents and glue it into one big string.

File

./advagg.missing.inc, line 1106
Advanced CSS/JS aggregation module.

Code

function advagg_missing_file_not_readable($filename, $aggregate_filename = '', $fs_read_failure = FALSE) {
  $write_aggregate = FALSE;
  $config_path = advagg_admin_config_root_path();
  list($css_path, $js_path) = advagg_get_root_files_dir();

  // Get cache of this report.
  $cid = 'advagg:file_issue:' . drupal_hash_base64($filename);
  $cache = cache_get($cid, 'cache_advagg_info');

  // Let other modules know about this missing file.
  // Call hook_advagg_missing_root_file().
  module_invoke_all('advagg_missing_root_file', $aggregate_filename, $filename, $cache);

  // Report to watchdog if this is not cached and it does not start in the
  // public dir and the advagg dirs.
  if (empty($cache) && strpos($filename, 'public://') !== 0 && strpos($filename, $css_path[1]) !== 0 && strpos($filename, $js_path[1]) !== 0) {
    if ($fs_read_failure) {
      watchdog('advagg', 'Reading from the file system failed. This can sometimes happen during a deployment and/or a clear cache operation. Filename: %file Aggregate Filename: %aggregate. If this continues to happen go to the <a href="@operations">Operations page</a> and under Drastic Measures - Reset the AdvAgg Files table click the Truncate advagg_files button.', array(
        '%file' => $filename,
        '%aggregate' => $aggregate_filename,
        '@operations' => url('admin/config/development/performance/advagg/operations', array(
          'fragment' => 'edit-reset-advagg-files',
        )),
      ), WATCHDOG_WARNING);
    }
    else {
      watchdog('advagg', 'The content hash for %file does not match the stored content hash from the database. Please <a href="@url">flush the advagg cache</a> under Smart Cache Flush. This can sometimes happen during a deployment. Filename: %file Aggregate Filename: %aggregate', array(
        '%file' => $filename,
        '%aggregate' => $aggregate_filename,
        '@url' => url($config_path . '/advagg/operations', array(
          'fragment' => 'edit-smart-flush',
        )),
      ), WATCHDOG_WARNING);
    }
    cache_set($cid, TRUE, 'cache_advagg_info', CACHE_TEMPORARY);
  }
  elseif (!empty($cache) && $cache->created < REQUEST_TIME - variable_get('advagg_file_read_failure_timeout', ADVAGG_FILE_READ_FAILURE_TIMEOUT)) {

    // Write the aggregate if it's been in a failure state for over 30 minutes.
    $write_aggregate = TRUE;
  }
  return $write_aggregate;
}