Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jodyHamilton/8f0811536f68b2066533 to your computer and use it in GitHub Desktop.
Save jodyHamilton/8f0811536f68b2066533 to your computer and use it in GitHub Desktop.
FG school mock time patch
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 728e4ec..394d746 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -215,7 +215,9 @@ define('LANGUAGE_RTL', 1);
* @see http://php.net/manual/reserved.variables.server.php
* @see http://php.net/manual/function.time.php
*/
-define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']);
+ // Moved to a phase of drupal_bootstrap so that we can pull this from a
+ // variable and mock request time for testing purposes.
+ #define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']);
/**
* Flag for drupal_set_title(); text is not sanitized, so run check_plain().
@@ -900,6 +902,8 @@ function variable_initialize($conf = array()) {
// cached pages.
if ($cached = cache_get('variables', 'cache_bootstrap')) {
$variables = $cached->data;
+ $time = !empty($variables['fruitguys_mock_time']) ? $variables['fruitguys_mock_time'] : $_SERVER['REQUEST_TIME'];
+ define('REQUEST_TIME', (int) $time);
}
else {
// Cache miss. Avoid a stampede.
@@ -913,6 +917,8 @@ function variable_initialize($conf = array()) {
else {
// Proceed with variable rebuild.
$variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed());
+ $time = isset($variables['fruitguys_mock_time']) ? $variables['fruitguys_mock_time'] : $_SERVER['REQUEST_TIME'];
+ define('REQUEST_TIME', (int) $time);
cache_set('variables', $variables, 'cache_bootstrap');
lock_release($name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment