FG school mock time patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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