function DrupalDatabaseCache::isValidBin
7.x cache.inc | 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 drupal-7.x/
includes/ cache.inc - Implements DrupalCacheInterface::clear().
File
- drupal-7.x/
includes/ cache.inc, line 563 - Functions and interfaces for cache handling.
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']));
}