Commit 9177c2a1 authored by Dries's avatar Dries

- Patch #1272686 by Paul Simard, bfroehle, beejeebus: convert existing cache_*...

- Patch #1272686 by Paul Simard, bfroehle, beejeebus: convert existing cache_* calls to the new cache()-> API.
parent f2144314
......@@ -4992,7 +4992,7 @@ function drupal_page_set_cache() {
if (variable_get('page_compression', TRUE) && extension_loaded('zlib')) {
$cache->data['body'] = gzencode($cache->data['body'], 9, FORCE_GZIP);
}
cache_set($cache->cid, $cache->data, 'cache_page', $cache->expire);
cache('page')->set($cache->cid, $cache->data, $cache->expire);
}
return $cache;
}
......@@ -5813,7 +5813,7 @@ function drupal_render_cache_get($elements) {
}
$bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
if (!empty($cid) && $cache = cache_get($cid, $bin)) {
if (!empty($cid) && $cache = cache($bin)->get($cid)) {
// Add additional libraries, JavaScript, CSS and other data attached
// to this element.
if (isset($cache->data['#attached'])) {
......@@ -5858,7 +5858,7 @@ function drupal_render_cache_set(&$markup, $elements) {
}
$bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
$expire = isset($elements['#cache']['expire']) ? $elements['#cache']['expire'] : CACHE_PERMANENT;
cache_set($cid, $data, $bin, $expire);
cache($bin)->set($cid, $data, $expire);
}
/**
......@@ -7149,7 +7149,7 @@ function drupal_flush_all_caches() {
$core = array('cache', 'cache_path', 'cache_filter', 'cache_bootstrap', 'cache_page');
$cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
foreach ($cache_tables as $table) {
cache_clear_all('*', $table, TRUE);
cache($table)->flush();
}
// Rebuild the bootstrap module list. We do this here so that developers
......@@ -7299,7 +7299,7 @@ function entity_get_info($entity_type = NULL) {
$langcode = $language->language;
if (empty($entity_info)) {
if ($cache = cache_get("entity_info:$langcode")) {
if ($cache = cache()->get("entity_info:$langcode")) {
$entity_info = $cache->data;
}
else {
......@@ -7342,7 +7342,7 @@ function entity_get_info($entity_type = NULL) {
}
// Let other modules alter the entity info.
drupal_alter('entity_info', $entity_info);
cache_set("entity_info:$langcode", $entity_info);
cache()->set("entity_info:$langcode", $entity_info);
}
}
......@@ -7360,7 +7360,7 @@ function entity_get_info($entity_type = NULL) {
function entity_info_cache_clear() {
drupal_static_reset('entity_get_info');
// Clear all languages.
cache_clear_all('entity_info:', 'cache', TRUE);
cache()->deletePrefix('entity_info:');
}
/**
......@@ -7738,13 +7738,13 @@ function archiver_get_info() {
$archiver_info = &drupal_static(__FUNCTION__, array());
if (empty($archiver_info)) {
$cache = cache_get('archiver_info');
$cache = cache()->get('archiver_info');
if ($cache === FALSE) {
// Rebuild the cache and save it.
$archiver_info = module_invoke_all('archiver_info');
drupal_alter('archiver_info', $archiver_info);
uasort($archiver_info, 'drupal_sort_weight');
cache_set('archiver_info', $archiver_info);
cache()->set('archiver_info', $archiver_info);
}
else {
$archiver_info = $cache->data;
......
......@@ -472,12 +472,12 @@ function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
* Fetch a form from cache.
*/
function form_get_cache($form_build_id, &$form_state) {
if ($cached = cache_get('form_' . $form_build_id, 'cache_form')) {
if ($cached = cache('form')->get('form_' . $form_build_id)) {
$form = $cached->data;
global $user;
if ((isset($form['#cache_token']) && drupal_valid_token($form['#cache_token'])) || (!isset($form['#cache_token']) && !$user->uid)) {
if ($cached = cache_get('form_state_' . $form_build_id, 'cache_form')) {
if ($cached = cache('form')->get('form_state_' . $form_build_id)) {
// Re-populate $form_state for subsequent rebuilds.
$form_state = $cached->data + $form_state;
......@@ -511,12 +511,12 @@ function form_set_cache($form_build_id, $form, $form_state) {
if ($GLOBALS['user']->uid) {
$form['#cache_token'] = drupal_get_token();
}
cache_set('form_' . $form_build_id, $form, 'cache_form', REQUEST_TIME + $expire);
cache('form')->set('form_' . $form_build_id, $form, REQUEST_TIME + $expire);
}
// Cache form state.
if ($data = array_diff_key($form_state, array_flip(form_state_keys_no_cache()))) {
cache_set('form_state_' . $form_build_id, $data, 'cache_form', REQUEST_TIME + $expire);
cache('form')->set('form_state_' . $form_build_id, $data, REQUEST_TIME + $expire);
}
}
......@@ -835,8 +835,8 @@ function drupal_process_form($form_id, &$form, &$form_state) {
// here, as we've finished with them. The in-memory copies are still
// here, though.
if (!variable_get('cache', 0) && !empty($form_state['values']['form_build_id'])) {
cache_clear_all('form_' . $form_state['values']['form_build_id'], 'cache_form');
cache_clear_all('form_state_' . $form_state['values']['form_build_id'], 'cache_form');
cache('form')->delete('form_' . $form_state['values']['form_build_id']);
cache('form')->delete('form_state_' . $form_state['values']['form_build_id']);
}
// If batches were set in the submit handlers, we process them now,
......
......@@ -53,7 +53,7 @@ function _locale_import_po($file, $langcode, $mode) {
// Clear cache and force refresh of JavaScript translations.
_locale_invalidate_js($langcode);
cache_clear_all('locale:', 'cache', TRUE);
cache()->deletePrefix('locale:');
// Rebuild the menu, strings may have changed.
menu_rebuild();
......
......@@ -441,14 +441,14 @@ function menu_get_item($path = NULL, $router_item = NULL) {
// Since there is no limit to the length of $path, use a hash to keep it
// short yet unique.
$cid = 'menu_item:' . hash('sha256', $path);
if ($cached = cache_get($cid, 'cache_menu')) {
if ($cached = cache('menu')->get($cid)) {
$router_item = $cached->data;
}
else {
$parts = array_slice($original_map, 0, MENU_MAX_PARTS);
$ancestors = menu_get_ancestors($parts);
$router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' => $ancestors))->fetchAssoc();
cache_set($cid, $router_item, 'cache_menu');
cache('menu')->set($cid, $router_item);
}
if ($router_item) {
// Allow modules to alter the router item before it is translated and
......@@ -1095,7 +1095,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
if (!isset($tree[$cid])) {
// If the static variable doesn't have the data, check {cache_menu}.
$cache = cache_get($cid, 'cache_menu');
$cache = cache('menu')->get($cid);
if ($cache && isset($cache->data)) {
// If the cache entry exists, it contains the parameters for
// menu_build_tree().
......@@ -1122,7 +1122,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
}
// Cache the tree building parameters using the page-specific cid.
cache_set($cid, $tree_parameters, 'cache_menu');
cache('menu')->set($cid, $tree_parameters);
}
// Build the tree using the parameters; the resulting tree will be cached
......@@ -1179,7 +1179,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
if (!isset($tree[$cid])) {
// If the static variable doesn't have the data, check {cache_menu}.
$cache = cache_get($cid, 'cache_menu');
$cache = cache('menu')->get($cid);
if ($cache && isset($cache->data)) {
// If the cache entry exists, it contains the parameters for
// menu_build_tree().
......@@ -1251,7 +1251,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
$tree_parameters['active_trail'] = $active_trail;
}
// Cache the tree building parameters using the page-specific cid.
cache_set($cid, $tree_parameters, 'cache_menu');
cache('menu')->set($cid, $tree_parameters);
}
// Build the tree using the parameters; the resulting tree will be cached
......@@ -1317,7 +1317,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) {
// If we do not have this tree in the static cache, check {cache_menu}.
if (!isset($trees[$tree_cid])) {
$cache = cache_get($tree_cid, 'cache_menu');
$cache = cache('menu')->get($tree_cid);
if ($cache && isset($cache->data)) {
$trees[$tree_cid] = $cache->data;
}
......@@ -1378,7 +1378,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) {
menu_tree_collect_node_links($data['tree'], $data['node_links']);
// Cache the data, if it is not already in the cache.
cache_set($tree_cid, $data, 'cache_menu');
cache('menu')->set($tree_cid, $data);
$trees[$tree_cid] = $data;
}
......@@ -2512,7 +2512,7 @@ function menu_cache_clear($menu_name = 'navigation') {
$cache_cleared = &drupal_static(__FUNCTION__, array());
if (empty($cache_cleared[$menu_name])) {
cache_clear_all('links:' . $menu_name . ':', 'cache_menu', TRUE);
cache('menu')->deletePrefix('links:' . $menu_name . ':');
$cache_cleared[$menu_name] = 1;
}
elseif ($cache_cleared[$menu_name] == 1) {
......@@ -2529,7 +2529,7 @@ function menu_cache_clear($menu_name = 'navigation') {
* might have been made to the router items or menu links.
*/
function menu_cache_clear_all() {
cache_clear_all('*', 'cache_menu', TRUE);
cache('menu')->flush();
menu_reset_static_cache();
}
......
......@@ -129,12 +129,12 @@ function system_list($type) {
if (isset($lists['bootstrap'])) {
return $lists['bootstrap'];
}
if ($cached = cache_get('bootstrap_modules', 'cache_bootstrap')) {
if ($cached = cache('bootstrap')->get('bootstrap_modules')) {
$bootstrap_list = $cached->data;
}
else {
$bootstrap_list = db_query("SELECT name, filename FROM {system} WHERE status = 1 AND bootstrap = 1 AND type = 'module' ORDER BY weight ASC, name ASC")->fetchAllAssoc('name');
cache_set('bootstrap_modules', $bootstrap_list, 'cache_bootstrap');
cache('bootstrap')->set('bootstrap_modules', $bootstrap_list);
}
// To avoid a separate database lookup for the filepath, prime the
// drupal_get_filename() static cache for bootstrap modules only.
......@@ -148,7 +148,7 @@ function system_list($type) {
}
// Otherwise build the list for enabled modules and themes.
elseif (!isset($lists['module_enabled'])) {
if ($cached = cache_get('system_list', 'cache_bootstrap')) {
if ($cached = cache('bootstrap')->get('system_list')) {
$lists = $cached->data;
}
else {
......@@ -178,7 +178,7 @@ function system_list($type) {
$lists['filepaths'][] = array('type' => $record->type, 'name' => $record->name, 'filepath' => $record->filename);
}
}
cache_set('system_list', $lists, 'cache_bootstrap');
cache('bootstrap')->set('system_list', $lists);
}
// To avoid a separate database lookup for the filepath, prime the
// drupal_get_filename() static cache with all enabled modules and themes.
......@@ -197,8 +197,7 @@ function system_list_reset() {
drupal_static_reset('system_list');
drupal_static_reset('system_rebuild_module_data');
drupal_static_reset('list_themes');
cache_clear_all('bootstrap_modules', 'cache_bootstrap');
cache_clear_all('system_list', 'cache_bootstrap');
cache('bootstrap')->deleteMultiple(array('bootstrap_modules', 'system_list'));
}
/**
......@@ -648,16 +647,16 @@ function module_implements($hook, $sort = FALSE, $reset = FALSE) {
// per request.
if ($reset) {
$implementations = array();
cache_set('module_implements', array(), 'cache_bootstrap');
cache('bootstrap')->set('module_implements', array());
drupal_static_reset('module_hook_info');
drupal_static_reset('drupal_alter');
cache_clear_all('hook_info', 'cache_bootstrap');
cache('bootstrap')->delete('hook_info');
return;
}
// Fetch implementations from cache.
if (empty($implementations)) {
$implementations = cache_get('module_implements', 'cache_bootstrap');
$implementations = cache('bootstrap')->get('module_implements');
if ($implementations === FALSE) {
$implementations = array();
}
......@@ -726,7 +725,7 @@ function module_hook_info() {
if (!isset($hook_info)) {
$hook_info = array();
$cache = cache_get('hook_info', 'cache_bootstrap');
$cache = cache('bootstrap')->get('hook_info');
if ($cache === FALSE) {
// Rebuild the cache and save it.
// We can't use module_invoke_all() here or it would cause an infinite
......@@ -747,7 +746,7 @@ function module_hook_info() {
$function($hook_info);
}
}
cache_set('hook_info', $hook_info, 'cache_bootstrap');
cache('bootstrap')->set('hook_info', $hook_info);
}
else {
$hook_info = $cache->data;
......@@ -769,7 +768,7 @@ function module_implements_write_cache() {
// optimized as tightly, and not doing so keeps the cache entry smaller.
if (isset($implementations['#write_cache']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD')) {
unset($implementations['#write_cache']);
cache_set('module_implements', $implementations, 'cache_bootstrap');
cache('bootstrap')->set('module_implements', $implementations);
}
}
......
......@@ -90,7 +90,7 @@ function drupal_lookup_path($action, $path = '', $path_language = NULL) {
$cache['map'][$path_language] = array();
// Load system paths from cache.
$cid = current_path();
if ($cached = cache_get($cid, 'cache_path')) {
if ($cached = cache('path')->get($cid)) {
$cache['system_paths'] = $cached->data;
// Now fetch the aliases corresponding to these system paths.
$args = array(
......@@ -212,7 +212,7 @@ function drupal_cache_system_paths() {
if ($paths = current($cache['map'])) {
$data = array_keys($paths);
$expire = REQUEST_TIME + (60 * 60 * 24);
cache_set($cid, $data, 'cache_path', $expire);
cache('path')->set($cid, $data, $expire);
}
}
}
......
......@@ -83,7 +83,7 @@ function _registry_update() {
$unchanged_resources = array();
$lookup_cache = array();
if ($cache = cache_get('lookup_cache', 'cache_bootstrap')) {
if ($cache = cache('bootstrap')->get('lookup_cache')) {
$lookup_cache = $cache->data;
}
foreach ($lookup_cache as $key => $file) {
......@@ -105,7 +105,7 @@ function _registry_update() {
// We have some unchanged resources, warm up the cache - no need to pay
// for looking them up again.
if (count($unchanged_resources) > 0) {
cache_set('lookup_cache', $unchanged_resources, 'cache_bootstrap');
cache('bootstrap')->set('lookup_cache', $unchanged_resources);
}
}
......
......@@ -280,7 +280,7 @@ function _theme_registry_callback($callback = NULL, array $arguments = array())
*/
function _theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL) {
// Check the theme registry cache; if it exists, use it.
$cache = cache_get("theme_registry:$theme->name", 'cache');
$cache = cache()->get("theme_registry:$theme->name");
if (isset($cache->data)) {
$registry = $cache->data;
}
......@@ -300,7 +300,7 @@ function _theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL)
* Write the theme_registry cache into the database.
*/
function _theme_save_registry($theme, $registry) {
cache_set("theme_registry:$theme->name", $registry);
cache()->set("theme_registry:$theme->name", $registry);
}
/**
......@@ -309,7 +309,7 @@ function _theme_save_registry($theme, $registry) {
* to add more theme hooks.
*/
function drupal_theme_rebuild() {
cache_clear_all('theme_registry', 'cache', TRUE);
cache()->deletePrefix('theme_registry');
}
/**
......
......@@ -827,7 +827,7 @@ function _block_render_blocks($region_blocks) {
// with node_access modules. We also preserve the submission of forms in
// blocks, by fetching from cache only if the request method is 'GET'
// (or 'HEAD').
if (!count(module_implements('node_grants')) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') && ($cid = _block_get_cache_id($block)) && ($cache = cache_get($cid, 'cache_block'))) {
if (!count(module_implements('node_grants')) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') && ($cid = _block_get_cache_id($block)) && ($cache = cache('block')->get($cid))) {
$array = $cache->data;
}
else {
......@@ -838,7 +838,7 @@ function _block_render_blocks($region_blocks) {
drupal_alter(array('block_view', "block_view_{$block->module}_{$block->delta}"), $array, $block);
if (isset($cid)) {
cache_set($cid, $array, 'cache_block', CACHE_TEMPORARY);
cache('block')->set($cid, $array, CACHE_TEMPORARY);
}
}
......
......@@ -1262,12 +1262,12 @@ function book_menu_subtree_data($link) {
$cid = 'links:' . $link['menu_name'] . ':subtree-cid:' . $link['mlid'];
if (!isset($tree[$cid])) {
$cache = cache_get($cid, 'cache_menu');
$cache = cache('menu')->get($cid);
if ($cache && isset($cache->data)) {
// If the cache entry exists, it will just be the cid for the actual data.
// This avoids duplication of large amounts of data.
$cache = cache_get($cache->data, 'cache_menu');
$cache = cache('menu')->get($cache->data);
if ($cache && isset($cache->data)) {
$data = $cache->data;
......@@ -1300,11 +1300,11 @@ function book_menu_subtree_data($link) {
$tree_cid = 'links:' . $item['menu_name'] . ':subtree-data:' . hash('sha256', serialize($data));
// Cache the data, if it is not already in the cache.
if (!cache_get($tree_cid, 'cache_menu')) {
cache_set($tree_cid, $data, 'cache_menu');
if (!cache('menu')->get($tree_cid)) {
cache('menu')->set($tree_cid, $data);
}
// Cache the cid of the (shared) data using the menu and item-specific cid.
cache_set($cid, $tree_cid, 'cache_menu');
cache('menu')->set($cid, $tree_cid);
}
// Check access for the current user to each item in the tree.
menu_tree_check_access($data['tree'], $data['node_links']);
......
......@@ -710,7 +710,7 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $
$data[$instance['field_name']] = $queried_entities[$id]->{$instance['field_name']};
}
$cid = "field:$entity_type:$id";
cache_set($cid, $data, 'cache_field');
cache('field')->set($cid, $data);
}
}
}
......@@ -984,7 +984,7 @@ function field_attach_update($entity_type, $entity) {
$entity_info = entity_get_info($entity_type);
if ($entity_info['field cache']) {
cache_clear_all("field:$entity_type:$id", 'cache_field');
cache('field')->delete("field:$entity_type:$id");
}
}
......@@ -1021,7 +1021,7 @@ function field_attach_delete($entity_type, $entity) {
$entity_info = entity_get_info($entity_type);
if ($entity_info['field cache']) {
cache_clear_all("field:$entity_type:$id", 'cache_field');
cache('field')->delete("field:$entity_type:$id");
}
}
......
......@@ -76,12 +76,12 @@ function _field_info_collate_types($reset = FALSE) {
if ($reset) {
$info = NULL;
// Clear all languages.
cache_clear_all('field_info_types:', 'cache_field', TRUE);
cache('field')->deletePrefix('field_info_types:');
return;
}
if (!isset($info)) {
if ($cached = cache_get("field_info_types:$langcode", 'cache_field')) {
if ($cached = cache('field')->get("field_info_types:$langcode")) {
$info = $cached->data;
}
else {
......@@ -149,7 +149,7 @@ function _field_info_collate_types($reset = FALSE) {
}
drupal_alter('field_storage_info', $info['storage types']);
cache_set("field_info_types:$langcode", $info, 'cache_field');
cache('field')->set("field_info_types:$langcode", $info);
}
}
......@@ -181,12 +181,12 @@ function _field_info_collate_fields($reset = FALSE) {
if ($reset) {
$info = NULL;
cache_clear_all('field_info_fields', 'cache_field');
cache('field')->delete('field_info_fields');
return;
}
if (!isset($info)) {
if ($cached = cache_get('field_info_fields', 'cache_field')) {
if ($cached = cache('field')->get('field_info_fields')) {
$info = $cached->data;
}
else {
......@@ -238,7 +238,7 @@ function _field_info_collate_fields($reset = FALSE) {
}
}
cache_set('field_info_fields', $info, 'cache_field');
cache('field')->set('field_info_fields', $info);
}
}
......
......@@ -772,7 +772,7 @@ function _field_extra_fields_pre_render($elements) {
* Clear the field info and field data caches.
*/
function field_cache_clear() {
cache_clear_all('*', 'cache_field', TRUE);
cache('field')->flush();
field_info_cache_clear();
}
......
......@@ -824,18 +824,18 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase {
$cid = "field:$entity_type:{$entity_init->ftid}";
// Check that no initial cache entry is present.
$this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no initial cache entry'));
$this->assertFalse(cache('field')->get($cid), t('Non-cached: no initial cache entry'));
// Save, and check that no cache entry is present.
$entity = clone($entity_init);
$entity->{$this->field_name}[$langcode] = $values;
field_attach_insert($entity_type, $entity);
$this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no cache entry on insert'));
$this->assertFalse(cache('field')->get($cid), t('Non-cached: no cache entry on insert'));
// Load, and check that no cache entry is present.
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no cache entry on load'));
$this->assertFalse(cache('field')->get($cid), t('Non-cached: no cache entry on load'));
// Cacheable entity type.
......@@ -846,24 +846,24 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase {
field_create_instance($instance);
// Check that no initial cache entry is present.
$this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no initial cache entry'));
$this->assertFalse(cache('field')->get($cid), t('Cached: no initial cache entry'));
// Save, and check that no cache entry is present.
$entity = clone($entity_init);
$entity->{$this->field_name}[$langcode] = $values;
field_attach_insert($entity_type, $entity);
$this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on insert'));
$this->assertFalse(cache('field')->get($cid), t('Cached: no cache entry on insert'));
// Load a single field, and check that no cache entry is present.
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity), FIELD_LOAD_CURRENT, array('field_id' => $this->field_id));
$cache = cache_get($cid, 'cache_field');
$this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on loading a single field'));
$cache = cache('field')->get($cid);
$this->assertFalse(cache('field')->get($cid), t('Cached: no cache entry on loading a single field'));
// Load, and check that a cache entry is present with the expected values.
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$cache = cache_get($cid, 'cache_field');
$cache = cache('field')->get($cid);
$this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load'));
// Update with different values, and check that the cache entry is wiped.
......@@ -871,12 +871,12 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase {
$entity = clone($entity_init);
$entity->{$this->field_name}[$langcode] = $values;
field_attach_update($entity_type, $entity);
$this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on update'));
$this->assertFalse(cache('field')->get($cid), t('Cached: no cache entry on update'));
// Load, and check that a cache entry is present with the expected values.
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$cache = cache_get($cid, 'cache_field');
$cache = cache('field')->get($cid);
$this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load'));
// Create a new revision, and check that the cache entry is wiped.
......@@ -885,18 +885,18 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase {
$entity = clone($entity_init);
$entity->{$this->field_name}[$langcode] = $values;
field_attach_update($entity_type, $entity);
$cache = cache_get($cid, 'cache_field');
$this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on new revision creation'));
$cache = cache('field')->get($cid);
$this->assertFalse(cache('field')->get($cid), t('Cached: no cache entry on new revision creation'));
// Load, and check that a cache entry is present with the expected values.
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$cache = cache_get($cid, 'cache_field');
$cache = cache('field')->get($cid);
$this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load'));
// Delete, and check that the cache entry is wiped.
field_attach_delete($entity_type, $entity);
$this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry after delete'));
$this->assertFalse(cache('field')->get($cid), t('Cached: no cache entry after delete'));
}
/**
......
......@@ -260,7 +260,7 @@ function filter_format_save($format) {
$return = SAVED_UPDATED;
// Clear the filter cache whenever a text format is updated.
cache_clear_all($format->format . ':', 'cache_filter', TRUE);
cache('filter')->deletePrefix($format->format . ':');
}
filter_formats_reset();
......@@ -290,7 +290,7 @@ function filter_format_disable($format) {
// Clear the filter cache whenever a text format is disabled.
filter_formats_reset();
cache_clear_all($format->format . ':', 'cache_filter', TRUE);
cache('filter')->deletePrefix($format->format . ':');
}
/**
......@@ -395,7 +395,7 @@ function filter_formats($account = NULL) {
// All available formats are cached for performance.
if (!isset($formats['all'])) {
if ($cache = cache_get("filter_formats:{$language->language}")) {
if ($cache = cache()->get("filter_formats:{$language->language}")) {
$formats['all'] = $cache->data;
}
else {
......@@ -407,7 +407,7 @@ function filter_formats($account = NULL) {
->execute()
->fetchAllAssoc('format');
cache_set("filter_formats:{$language->language}", $formats['all']);
cache()->set("filter_formats:{$language->language}", $formats['all']);
}
}
......@@ -430,8 +430,8 @@ function filter_formats($account = NULL) {
* @see filter_formats()
*/
function filter_formats_reset() {
cache_clear_all('filter_formats', 'cache', TRUE);
cache_clear_all('filter_list_format', 'cache', TRUE);
cache()->deletePrefix('filter_formats');
cache()->deletePrefix('filter_list_format');
drupal_static_reset('filter_list_format');
drupal_static_reset('filter_formats');
}
......@@ -657,7 +657,7 @@ function filter_list_format($format_id) {
$filter_info = filter_get_filters();
if (!isset($filters['all'])) {
if ($cache = cache_get('filter_list_format')) {
if ($cache = cache()->get('filter_list_format')) {
$filters['all'] = $cache->data;
}
else {
......@@ -665,7 +665,7 @@ function filter_list_format($format_id) {
foreach ($result as $record) {
$filters['all'][$record->format][$record->name] = $record;
}
cache_set('filter_list_format', $filters['all']);
cache()->set('filter_list_format', $filters['all']);
}
}
......@@ -731,7 +731,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE)
$cache_id = '';
if ($cache) {
$cache_id = $format->format . ':' . $langcode . ':' . hash('sha256', $text);
if ($cached = cache_get($cache_id, 'cache_filter')) {
if ($cached = cache('filter')->get($cache_id)) {
return $cached->data;
}
}
......@@ -765,7 +765,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE)
// automatically flushed when the text format is updated.
// @see filter_format_save()
if ($cache) {
cache_set($cache_id, $text, 'cache_filter');
cache('filter')->set($cache_id, $text);
}
return $text;
......
......@@ -110,7 +110,7 @@ function hook_image_style_delete($style) {
*/
function hook_image_style_flush($style) {
// Empty cached data that contains information about the style.
cache_clear_all('*', 'cache_mymodule', TRUE);
cache('mymodule')->flush();
}
/**
......
......@@ -492,7 +492,7 @@ function image_styles() {
// Grab from cache or build the array.
if (!isset($styles)) {
if ($cache = cache_get('image_styles', 'cache')) {
if ($cache = cache()->get('image_styles')) {
$styles = $cache->data;
}
else {
......@@ -534,7 +534,7 @@ function image_styles() {
}
drupal_alter('image_styles', $styles);
cache_set('image_styles', $styles);
cache()->set('image_styles', $styles);
}
}
......@@ -827,8 +827,8 @@ function image_style_flush($style) {
module_invoke_all('image_style_flush', $style);