function DrupalDatabaseCache::isValidBin

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

File

includes/cache.inc, line 568
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']));
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!cache.inc/function/DrupalDatabaseCache::isValidBin/7.x