diff --git a/includes/callback.inc b/includes/callback.inc index a9e4b69..75f8d8c 100644 --- a/includes/callback.inc +++ b/includes/callback.inc @@ -184,7 +184,7 @@ function js_callback_bootstrap(array &$info) { // At this point in the execution flow it is safe to perform a full // bootstrap in case of cache misses. - if (!empty($GLOBALS['conf']['js_cache'])) { + if ($info['cache']) { JsCache::setFullBootstrap(TRUE); } } diff --git a/js.api.php b/js.api.php index a531b58..604370c 100644 --- a/js.api.php +++ b/js.api.php @@ -53,13 +53,14 @@ * instance, loading an entity when entity cache is cold may result in some * data not being loaded and entity cache being corrupt; saving that entity * in subsequent requests may even lead to data loss, if the cache entry was - * not refreshed meanwhile. A possible solution is raising the bootstrap - * level to full, although this defeats the purpose of using this module. - * An alternative solution is monitoring the code paths triggered by the + * not refreshed meanwhile. By default JS will work around the corrupt cache + * issue automatically by performing a full bootstrap whenever a cache miss + * is detected, however the general issue with APIs performing storage + * writes remains. A possible solution is raising the bootstrap level to + * full, although this defeats the purpose of using this module. An + * alternative solution is monitoring the code paths triggered by the * callback via the "xhprof" integration and make sure all required - * dependencies are actually loaded. Another viable solution is enabling the - * JS custom cache handler by setting "$conf['js_cache'] = TRUE;" in your - * php settings file. This will trigger a full bootstrap on cache misses. + * dependencies are actually loaded. * - includes: (optional) Load additional files from the /includes directory, * without the extension. * - dependencies: (optional) Load additional modules for this callback. @@ -113,6 +114,8 @@ * browser. It is strongly recommended that this is not disabled, otherwise * your site will be susceptible to XSS attacks and be considered * "insecure". + * - cache: (optional) Flag indicating whether a full bootstrap should be + * performed when detecting a cache miss. Defaults to TRUE. */ function hook_js_info() { // Simple callback definition: diff --git a/js.module b/js.module index 4213c87..56bc5e7 100644 --- a/js.module +++ b/js.module @@ -490,10 +490,8 @@ function js_execute_request() { // Initialize the JS cache handler. $memcache = !empty($conf['cache_default_class']) && $conf['cache_default_class'] === 'MemCacheDrupal'; - if (!empty($conf['js_cache'])) { - module_load_include('inc', 'js', 'includes/cache'); - js_cache_initialize(); - } + module_load_include('inc', 'js', 'includes/cache'); + js_cache_initialize(); // Memcache requires an additional bootstrap phase to access variables. if ($memcache) { js_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES); @@ -806,6 +804,7 @@ function js_get_callback($module = NULL, $callback = NULL, $reset = FALSE) { 'token' => TRUE, 'xhprof' => FALSE, 'xss' => TRUE, + 'cache' => TRUE, ); } }