function advagg_bundle_built in Advanced CSS/JS Aggregation 7
Same name and namespace in other branches
- 6 advagg.module \advagg_bundle_built()
See if this bundle has been built.
Parameters
$filepath: filename
Return value
Boolean indicating if the bundle already exists.
1 call to advagg_bundle_built()
- advagg_css_js_file_builder in ./
advagg.module - Aggregate CSS/JS files, putting them in the files directory.
File
- ./
advagg.module, line 1442 - Advanced CSS/JS aggregation module
Code
function advagg_bundle_built($filepath) {
// Don't use the cache if not selected.
if (!variable_get('advagg_bundle_built_mode', ADVAGG_BUNDLE_BUILT_MODE)) {
advagg_clearstatcache(TRUE, $filepath);
return file_exists($filepath);
}
$data = advagg_get_bundle_from_filename(basename($filepath));
if (is_array($data)) {
list($type, $md5, $counter) = $data;
}
else {
return FALSE;
}
$data = cache_get($filepath, 'cache_advagg');
if (isset($data->data)) {
// Refresh timestamp if older then 12 hours.
if (REQUEST_TIME - $data->data > variable_get('advagg_file_last_used_interval', ADVAGG_FILE_LAST_USED_INTERVAL)) {
cache_set($filepath, REQUEST_TIME, 'cache_advagg', CACHE_PERMANENT);
// TODO Please review the conversion of this statement to the D7 database API syntax.
/* db_query("UPDATE {advagg_bundles} SET timestamp = %d WHERE bundle_md5 = '%s'", REQUEST_TIME, $md5) */
db_update('advagg_bundles')
->fields(array(
'timestamp' => REQUEST_TIME,
))
->condition('bundle_md5', $md5)
->execute();
}
return TRUE;
}
// If not in cache check disk.
advagg_clearstatcache(TRUE, $filepath);
if (file_exists($filepath)) {
if (@filesize($filepath) == 0) {
return FALSE;
}
}
else {
return FALSE;
}
// File existed on disk; place in cache.
cache_set($filepath, REQUEST_TIME, 'cache_advagg', CACHE_PERMANENT);
// TODO Please review the conversion of this statement to the D7 database API syntax.
/* db_query("UPDATE {advagg_bundles} SET timestamp = %d WHERE bundle_md5 = '%s'", REQUEST_TIME, $md5) */
db_update('advagg_bundles')
->fields(array(
'timestamp' => REQUEST_TIME,
))
->condition('bundle_md5', $md5)
->execute();
return TRUE;
}