function DrupalDatabaseCache::isValidBin
Checks if $this->bin represents a valid cache table.
This check is required to ensure that non-cache tables are not truncated accidentally when calling cache_clear_all().
Return value
boolean
1 call to DrupalDatabaseCache::isValidBin()
- DrupalDatabaseCache::clear in includes/
cache.inc - Implements DrupalCacheInterface::clear().
File
-
includes/
cache.inc, line 578
Class
- DrupalDatabaseCache
- Defines a default cache implementation.
Code
function isValidBin() {
if ($this->bin == 'cache' || substr($this->bin, 0, 6) == 'cache_') {
// Skip schema check for bins with standard table names.
return TRUE;
}
// These fields are required for any cache table.
$fields = array(
'cid',
'data',
'expire',
'created',
'serialized',
);
// Load the table schema.
$schema = drupal_get_schema($this->bin);
// Confirm that all fields are present.
return isset($schema['fields']) && !array_diff($fields, array_keys($schema['fields']));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.