/** * Refresh the in-memory set of variables. * * Refresh the in-memory set of variables. Useful after a page request is made * that changes a variable in a different thread. * * This is an overridden version of the function provided by the Drupal test * module. It maintains any settings created in settings.php (and it's * corresponding global.inc) file. * * In other words calling a settings page with $this->drupalPost() with a * changed value would update a variable to reflect that change, but in * the thread that made the call (thread running the test) the changed * variable would not be picked up. * * This method clears the variables cache and loads a fresh copy from * the database to ensure that the most up-to-date set of variables is loaded. */ protected function refreshVariables() { global $conf; cache_clear_all('variables', 'cache_bootstrap'); $variables = variable_initialize(); // Merge updated database variables back into $conf. foreach ($variables as $name => $value) { $conf[$name] = $value; } return $conf; }
/** * Refresh the in-memory set of variables and state values. Useful after a * page request is made that changes a variable in a different thread. * * In other words calling a settings page with $this->backdropPost() with a changed * value would update a variable to reflect that change, but in the thread that * made the call (thread running the test) the changed variable would not be * picked up. * * This method clears the variables cache and loads a fresh copy from the database * to ensure that the most up-to-date set of variables is loaded. */ protected function refreshVariables() { global $conf; cache('bootstrap')->delete('variables'); $conf = variable_initialize(); backdrop_static_reset('states'); backdrop_static_reset('config'); }
/** * Refresh the in-memory set of variables. Useful after a page request is made * that changes a variable in a different thread. * * In other words calling a settings page with $this->drupalPost() with a changed * value would update a variable to reflect that change, but in the thread that * made the call (thread running the test) the changed variable would not be * picked up. * * This method clears the variables cache and loads a fresh copy from the database * to ensure that the most up-to-date set of variables is loaded. */ protected function refreshVariables() { global $conf; cache_clear_all('variables', 'cache_bootstrap'); $conf = variable_initialize(); }
/** * Refresh the in-memory set of variables. Useful after a page request is made * that changes a variable in a different thread. * * In other words calling a settings page with $this->drupalPost() with a changed * value would update a variable to reflect that change, but in the thread that * made the call (thread running the test) the changed variable would not be * picked up. * * This method clears the variables cache and loads a fresh copy from the database * to ensure that the most up-to-date set of variables is loaded. */ protected function refreshVariables() { global $conf; if (!defined('DRUPAL_CORE_VERSION')) { define('DRUPAL_CORE_VERSION', "8"); } if (DRUPAL_CORE_VERSION == "7") { cache_clear_all('variables', 'cache_bootstrap'); } else { cache('bootstrap')->delete('variables'); } $conf = variable_initialize(); }
/** * Read a drupal variable. * * @param string $name * The variable name. * @param null $default * Pass in a default to use of the variable doesn't exist. * * @return bool|mixed * false on failure, the variable on success. */ public function readVariable($name, $default = null) { global $conf; $conf = variable_initialize($conf); return variable_get($name, $default); }
// Drupal will probably miscalculate the base_url if we're bootstrapping from handler.php if (!isset($base_url)) { $base_root = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http'; // As $_SERVER['HTTP_HOST'] allows user input, ensure it only contains valid characters. $base_url = $base_root . '://www.' . preg_replace('/[^a-z0-9-:._]/i', '', $_SERVER['HTTP_HOST']); // Unlike $_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME'] cannot be modified by a visitor. $script_path_array = explode('/', $_SERVER['SCRIPT_NAME']); $base_path_array = explode('/', $base_path); $base_dir = implode('/', array_intersect($base_path_array, $script_path_array)); $base_url .= $base_dir; } // Bootstrap Drupal. require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); // Initialize configuration variables, using values from settings.php if available. $conf = variable_initialize(isset($conf) ? $conf : array()); // Add file.inc for various file functions used in phpfreechat require_once './includes/file.inc'; // Add common.inc to be able to use drupal_get_path later require_once './includes/common.inc'; // Add user module to handle user permissions in phpfreechat require_once drupal_get_path('module', 'user') . '/user.module'; // We will need to load the current node if (!function_exists('arg')) { // Use HTTP_REFERER to extract the node ID $path = str_replace(array($base_url . '/', '/?q='), '', $_SERVER['HTTP_REFERER']); // Get the real path from the current request require_once './includes/path.inc'; $args = explode('/', drupal_get_normal_path($path)); $result = db_query('SELECT * FROM {node} n INNER JOIN {phpfreechat} pfc ON pfc.nid = n.nid WHERE n.nid = :nid', array(':nid' => $args[1])); $node = $result->fetchObject();
/** * Makes sure all variables and branches have been reset. */ function resetBranchesAndCache() { cache_clear_all('variables', 'cache_bootstrap', 'cache'); drupal_static_reset(); variable_initialize(); api_reset_branches(); }