| 1 |
<?php
|
| 2 |
// $Id: cache-install.inc,v 1.5 2009/09/13 17:49:51 dries Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* A stub cache implementation to be used during the installation
|
| 6 |
* process when database access is not yet available. Because Drupal's
|
| 7 |
* caching system never requires that cached data be present, these
|
| 8 |
* stub functions can short-circuit the process and sidestep the
|
| 9 |
* need for any persistent storage. Obviously, using this cache
|
| 10 |
* implementation during normal operations would have a negative impact
|
| 11 |
* on performance.
|
| 12 |
*/
|
| 13 |
class DrupalFakeCache extends DrupalDatabaseCache implements DrupalCacheInterface {
|
| 14 |
function get($cid) {
|
| 15 |
return FALSE;
|
| 16 |
}
|
| 17 |
|
| 18 |
function getMultiple(&$cids) {
|
| 19 |
return array();
|
| 20 |
}
|
| 21 |
|
| 22 |
function set($cid, $data, $expire = CACHE_PERMANENT, array $headers = NULL) {
|
| 23 |
}
|
| 24 |
|
| 25 |
function clear($cid = NULL, $wildcard = FALSE) {
|
| 26 |
// If there is a database cache, attempt to clear it whenever possible. The
|
| 27 |
// reason for doing this is that the database cache can accumulate data
|
| 28 |
// during installation due to any full bootstraps that may occur at the
|
| 29 |
// same time (for example, AJAX requests triggered by the installer). If we
|
| 30 |
// didn't try to clear it whenever this function is called, the data in the
|
| 31 |
// cache would become stale; for example, the installer sometimes calls
|
| 32 |
// variable_set(), which updates the {variable} table and then clears the
|
| 33 |
// cache to make sure that the next page request picks up the new value.
|
| 34 |
// Not actually clearing the cache here therefore leads old variables to be
|
| 35 |
// loaded on the first page requests after installation, which can cause
|
| 36 |
// subtle bugs, some of which would not be fixed unless the site
|
| 37 |
// administrator cleared the cache manually.
|
| 38 |
try {
|
| 39 |
if (function_exists('drupal_install_initialize_database')) {
|
| 40 |
drupal_install_initialize_database();
|
| 41 |
parent::clear($cid, $wildcard);
|
| 42 |
}
|
| 43 |
}
|
| 44 |
// If the attempt at clearing the cache causes an error, that means that
|
| 45 |
// either the database connection is not set up yet or the relevant cache
|
| 46 |
// table in the database has not yet been created, so we can safely do
|
| 47 |
// nothing here.
|
| 48 |
catch (Exception $e) {
|
| 49 |
}
|
| 50 |
}
|
| 51 |
|
| 52 |
function isEmpty() {
|
| 53 |
return TRUE;
|
| 54 |
}
|
| 55 |
}
|