Projet

Général

Profil

Paste
Télécharger (2,43 ko) Statistiques
| Branche: | Révision:

root / drupal7 / includes / cache-install.inc @ 08f5d39b

1
<?php
2

    
3
/**
4
 * @file
5
 * Provides a stub cache implementation to be used during installation.
6
 */
7

    
8
/**
9
 * Defines a stub cache implementation to be used during installation.
10
 *
11
 * The stub implementation is needed when database access is not yet available.
12
 * Because Drupal's caching system never requires that cached data be present,
13
 * these stub functions can short-circuit the process and sidestep the need for
14
 * any persistent storage. Obviously, using this cache implementation during
15
 * normal operations would have a negative impact on performance.
16
 */
17
class DrupalFakeCache extends DrupalDatabaseCache implements DrupalCacheInterface {
18

    
19
  /**
20
   * Overrides DrupalDatabaseCache::get().
21
   */
22
  function get($cid) {
23
    return FALSE;
24
  }
25

    
26
  /**
27
   * Overrides DrupalDatabaseCache::getMultiple().
28
   */
29
  function getMultiple(&$cids) {
30
    return array();
31
  }
32

    
33
  /**
34
   * Overrides DrupalDatabaseCache::set().
35
   */
36
  function set($cid, $data, $expire = CACHE_PERMANENT) {
37
  }
38

    
39
  /**
40
   * Overrides DrupalDatabaseCache::clear().
41
   */
42
  function clear($cid = NULL, $wildcard = FALSE) {
43
    // If there is a database cache, attempt to clear it whenever possible. The
44
    // reason for doing this is that the database cache can accumulate data
45
    // during installation due to any full bootstraps that may occur at the
46
    // same time (for example, Ajax requests triggered by the installer). If we
47
    // didn't try to clear it whenever this function is called, the data in the
48
    // cache would become stale; for example, the installer sometimes calls
49
    // variable_set(), which updates the {variable} table and then clears the
50
    // cache to make sure that the next page request picks up the new value.
51
    // Not actually clearing the cache here therefore leads old variables to be
52
    // loaded on the first page requests after installation, which can cause
53
    // subtle bugs, some of which would not be fixed unless the site
54
    // administrator cleared the cache manually.
55
    try {
56
      if (class_exists('Database')) {
57
        parent::clear($cid, $wildcard);
58
      }
59
    }
60
    // If the attempt at clearing the cache causes an error, that means that
61
    // either the database connection is not set up yet or the relevant cache
62
    // table in the database has not yet been created, so we can safely do
63
    // nothing here.
64
    catch (Exception $e) {
65
    }
66
  }
67

    
68
  /**
69
   * Overrides DrupalDatabaseCache::isEmpty().
70
   */
71
  function isEmpty() {
72
    return TRUE;
73
  }
74
}