Commit 2c381622 authored by webchick's avatar webchick

#88264 by Rob Loach and kscheirer: Make variable_get()'s defaultparameter...

#88264 by Rob Loach and kscheirer: Make variable_get()'s defaultparameter default to NULL so that NULLs do not need to be specified.
parent 9544110e
......@@ -631,7 +631,7 @@ function variable_init($conf = array()) {
* @return
* The value of the variable.
*/
function variable_get($name, $default) {
function variable_get($name, $default = NULL) {
global $conf;
return isset($conf[$name]) ? $conf[$name] : $default;
......@@ -1046,7 +1046,7 @@ function drupal_is_denied($ip) {
// Because this function is called on every page request, we first check
// for an array of IP addresses in settings.php before querying the
// database.
$blocked_ips = variable_get('blocked_ips', NULL);
$blocked_ips = variable_get('blocked_ips');
if (isset($blocked_ips) && is_array($blocked_ips)) {
return in_array($ip, $blocked_ips);
}
......
......@@ -1407,7 +1407,7 @@ function file_scan_directory($dir, $mask, $nomask = '/(\.\.?|CVS)$/', $callback
* A string containing a temp directory.
*/
function file_directory_temp() {
$temporary_directory = variable_get('file_directory_temp', NULL);
$temporary_directory = variable_get('file_directory_temp');
if (is_null($temporary_directory)) {
$directories = array();
......
......@@ -72,7 +72,7 @@ function _color_theme_select_form_alter(&$form, &$form_state) {
// Use the generated screenshot in the theme list.
$themes = list_themes();
foreach (element_children($form) as $theme) {
if ($screenshot = variable_get('color_' . $theme . '_screenshot', NULL)) {
if ($screenshot = variable_get('color_' . $theme . '_screenshot')) {
if (isset($form[$theme]['screenshot'])) {
$form[$theme]['screenshot']['#markup'] = theme('image', $screenshot, '', '', array('class' => 'screenshot'), FALSE);
}
......@@ -127,7 +127,7 @@ function _color_page_alter(&$vars) {
}
// Override logo.
$logo = variable_get('color_' . $theme_key . '_logo', NULL);
$logo = variable_get('color_' . $theme_key . '_logo');
if ($logo && $vars['logo'] && preg_match('!' . $theme_key . '/logo.png$!', $vars['logo'])) {
$vars['logo'] = base_path() . $logo;
}
......
......@@ -172,7 +172,7 @@ function locale_update_6004() {
function locale_update_6005() {
foreach (node_get_types() as $type => $content_type) {
// Default to NULL, so we can skip dealing with non-existent settings.
$setting = variable_get('language_' . $type, NULL);
$setting = variable_get('language_' . $type);
if ($type == 'default' && is_numeric($setting)) {
// language_default was overwritten with the content type setting,
// so reset the default language and save the content type setting.
......
......@@ -151,7 +151,7 @@ class BootstrapVariableTestCase extends DrupalWebTestCase {
// Setting and retrieving values.
$variable = $this->randomName();
variable_set('simpletest_bootstrap_variable_test', $variable);
$this->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test', NULL), t('Setting and retrieving values'));
$this->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test'), t('Setting and retrieving values'));
// Make sure the variable persists across multiple requests.
$this->drupalGet('system-test/variable-get');
......@@ -164,6 +164,17 @@ class BootstrapVariableTestCase extends DrupalWebTestCase {
$this->assertIdentical($variable, $default_value, t('Deleting variables'));
}
/**
* Makes sure that the default variable parameter is passed through okay.
*/
function testVariableDefaults() {
// Tests passing nothing through to the default.
$this->assertIdentical(NULL, variable_get('simpletest_bootstrap_variable_test'), t('Variables are correctly defaulting to NULL.'));
// Tests passing 5 to the default parameter.
$this->assertIdentical(5, variable_get('simpletest_bootstrap_variable_test', 5), t('The default variable parameter is passed through correctly.'));
}
}
/**
......
......@@ -1322,7 +1322,7 @@ function hook_requirements($phase) {
// Report cron status
if ($phase == 'runtime') {
$cron_last = variable_get('cron_last', NULL);
$cron_last = variable_get('cron_last');
if (is_numeric($cron_last)) {
$requirements['cron']['value'] = $t('Last run !time ago', array('!time' => format_interval(REQUEST_TIME - $cron_last)));
......
......@@ -134,7 +134,7 @@ function system_requirements($phase) {
$help = $t('For more information, see the online handbook entry for <a href="@cron-handbook">configuring cron jobs</a>.', array('@cron-handbook' => 'http://drupal.org/cron'));
// Determine when cron last ran.
$cron_last = variable_get('cron_last', NULL);
$cron_last = variable_get('cron_last');
if (!is_numeric($cron_last)) {
$cron_last = variable_get('install_time', 0);
}
......@@ -2491,7 +2491,7 @@ function system_update_6041() {
*/
function system_update_6042() {
foreach (list_themes() as $theme) {
$stylesheet = variable_get('color_' . $theme->name . '_stylesheet', NULL);
$stylesheet = variable_get('color_' . $theme->name . '_stylesheet');
if (!empty($stylesheet)) {
variable_set('color_' . $theme->name . '_stylesheets', array($stylesheet));
variable_del('color_' . $theme->name . '_stylesheet');
......@@ -2853,12 +2853,12 @@ function system_update_7004(&$sandbox) {
}
}
// Rename forum module's block variables.
$forum_block_num_0 = variable_get('forum_block_num_0', NULL);
$forum_block_num_0 = variable_get('forum_block_num_0');
if (isset($forum_block_num_0)) {
variable_set('forum_block_num_active', $forum_block_num_0);
variable_del('forum_block_num_0');
}
$forum_block_num_1 = variable_get('forum_block_num_1', NULL);
$forum_block_num_1 = variable_get('forum_block_num_1');
if (isset($forum_block_num_1)) {
variable_set('forum_block_num_new', $forum_block_num_1);
variable_del('forum_block_num_1');
......@@ -3090,7 +3090,7 @@ function system_update_7013() {
$timezones = system_time_zones();
// If the contributed Date module set a default time zone name, use this
// setting as the default time zone.
if (($timezone_name = variable_get('date_default_timezone_name', NULL)) && isset($timezones[$timezone_name])) {
if (($timezone_name = variable_get('date_default_timezone_name')) && isset($timezones[$timezone_name])) {
$timezone = $timezone_name;
}
// If the contributed Event module has set a default site time zone, look up
......
......@@ -42,7 +42,7 @@ class UserRegistrationTestCase extends DrupalWebTestCase {
$this->assertEqual($user->signature, '', t('Correct signature field.'));
$this->assertTrue(($user->created > REQUEST_TIME - 20 ), t('Correct creation time.'));
$this->assertEqual($user->status, variable_get('user_register', 1) == 1 ? 1 : 0, t('Correct status field.'));
$this->assertEqual($user->timezone, variable_get('date_default_timezone', NULL), t('Correct time zone field.'));
$this->assertEqual($user->timezone, variable_get('date_default_timezone'), t('Correct time zone field.'));
$this->assertEqual($user->language, '', t('Correct language field.'));
$this->assertEqual($user->picture, '', t('Correct picture field.'));
$this->assertEqual($user->init, $mail, t('Correct init field.'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment