Commit 3780b176 authored by Dries's avatar Dries

- Patch #921606 by munzirtaha, bleen18: various code uses is_null().

parent 88bc80a5
......@@ -1616,7 +1616,7 @@ function format_rss_item($title, $link, $description, $args = array()) {
* Format XML elements.
*
* @param $array
* An array where each item represent an element and is either a:
* An array where each item represents an element and is either a:
* - (key => value) pair (<key>value</key>)
* - Associative array with fields:
* - 'key': element name
......
......@@ -2193,11 +2193,11 @@ function drupal_dirname($uri) {
* @ingroup php_wrappers
*/
function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) {
if (is_null($mode)) {
if (!isset($mode)) {
$mode = variable_get('file_chmod_directory', 0775);
}
if (is_null($context)) {
if (!isset($context)) {
return mkdir($uri, $mode, $recursive);
}
else {
......@@ -2282,7 +2282,7 @@ function drupal_tempnam($directory, $prefix) {
function file_directory_temp() {
$temporary_directory = variable_get('file_directory_temp', NULL);
if (is_null($temporary_directory)) {
if (!isset($temporary_directory)) {
$directories = array();
// Has PHP been set with an upload_tmp_dir?
......
......@@ -2096,7 +2096,7 @@ function form_type_checkboxes_value($element, $input = FALSE) {
// checkboxes to the server at all). This will not affect non-programmatic
// form submissions, since a checkbox can never legitimately be NULL.
foreach ($input as $key => $value) {
if (is_null($value)) {
if (!isset($value)) {
unset($input[$key]);
}
}
......@@ -4009,7 +4009,7 @@ function _batch_queue($batch_set) {
// The class autoloader is not available when running update.php, so make
// sure the files are manually included.
if (is_null($queues)) {
if (!isset($queues)) {
$queues = array();
require_once DRUPAL_ROOT . '/modules/system/system.queue.inc';
require_once DRUPAL_ROOT . '/includes/batch.queue.inc';
......
......@@ -1119,7 +1119,7 @@ function theme_get_setting($setting_name, $theme = NULL) {
$cache = &drupal_static(__FUNCTION__, array());
// If no key is given, use the current theme if we can determine it.
if (is_null($theme)) {
if (!isset($theme)) {
$theme = !empty($GLOBALS['theme_key']) ? $GLOBALS['theme_key'] : '';
}
......
......@@ -106,7 +106,7 @@ function _field_sql_storage_indexname($name, $index) {
*/
function _field_sql_storage_etid($entity_type) {
$etid = variable_get('field_sql_storage_' . $entity_type . '_etid', NULL);
if (is_null($etid)) {
if (!isset($etid)) {
$etid = db_insert('field_config_entity_type')->fields(array('type' => $entity_type))->execute();
variable_set('field_sql_storage_' . $entity_type . '_etid', $etid);
}
......
......@@ -152,7 +152,7 @@ function field_test_field_language_alter(&$display_language, $context) {
function field_test_memorize($key = NULL, $value = NULL) {
$memorize = &drupal_static(__FUNCTION__, NULL);
if (is_null($key)) {
if (!isset($key)) {
$return = $memorize;
$memorize = array();
return $return;
......
......@@ -70,7 +70,7 @@ function field_test_field_storage_details_alter(&$details, $field) {
* Helper function: stores or retrieves data from the 'storage backend'.
*/
function _field_test_storage_data($data = NULL) {
if (is_null($data)) {
if (!isset($data)) {
return variable_get('field_test_storage_data', array());
}
else {
......@@ -318,7 +318,7 @@ function field_test_field_storage_query($field_id, $conditions, $count, &$cursor
}
if ($match) {
if (is_null($skip) || $skipped >= $skip) {
if (!isset($skip) || $skipped >= $skip) {
$cursor++;
// If querying all revisions and the entity type has revisions, we need
// to key the results by revision_ids.
......
......@@ -68,7 +68,7 @@ function field_ui_inactive_message($entity_type, $bundle) {
* This is intended as a callback for array_reduce().
*/
function _field_ui_reduce_order($array, $a) {
$array = is_null($array) ? array() : $array;
$array = !isset($array) ? array() : $array;
if ($a['name']) {
$array[] = $a['name'];
}
......
......@@ -959,7 +959,7 @@ function search_form($form, &$form_state, $action = '', $keys = '', $type = NULL
if (!$action) {
$action = 'search/' . $module_info['path'];
}
if (is_null($prompt)) {
if (!isset($prompt)) {
$prompt = t('Enter your keywords');
}
......
......@@ -466,7 +466,7 @@ function batch_test_stack($data = NULL, $reset = FALSE) {
if ($reset) {
variable_del('batch_test_stack');
}
if (is_null($data)) {
if (!isset($data)) {
return variable_get('batch_test_stack', array());
}
$stack = variable_get('batch_test_stack', array());
......
......@@ -174,7 +174,7 @@ class FileTestCase extends DrupalWebTestCase {
*/
function createDirectory($path = NULL) {
// A directory to operate on.
if (is_null($path)) {
if (!isset($path)) {
$path = file_default_scheme() . '://' . $this->randomName();
}
$this->assertTrue(drupal_mkdir($path) && is_dir($path), t('Directory was created successfully.'));
......@@ -198,12 +198,12 @@ class FileTestCase extends DrupalWebTestCase {
* File object.
*/
function createFile($filepath = NULL, $contents = NULL, $scheme = 'public') {
if (is_null($filepath)) {
if (!isset($filepath)) {
$filepath = $this->randomName();
}
$filepath = $scheme . '://' . $filepath;
if (is_null($contents)) {
if (!isset($contents)) {
$contents = "file_put_contents() doesn't seem to appreciate empty strings so let's put in some data.";
}
......@@ -282,7 +282,7 @@ class FileHookTestCase extends FileTestCase {
function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) {
$actual_count = count(file_test_get_calls($hook));
if (is_null($message)) {
if (!isset($message)) {
if ($actual_count == $expected_count) {
$message = t('hook_file_@name was called correctly.', array('@name' => $hook));
}
......
......@@ -103,7 +103,7 @@ function syslog_watchdog(array $log_entry) {
'!referer' => $log_entry['referer'],
'!uid' => $log_entry['user']->uid,
'!link' => strip_tags($log_entry['link']),
'!message' => strip_tags(is_null($log_entry['variables']) ? $log_entry['message'] : strtr($log_entry['message'], $log_entry['variables'])),
'!message' => strip_tags(!isset($log_entry['variables']) ? $log_entry['message'] : strtr($log_entry['message'], $log_entry['variables'])),
));
syslog($log_entry['severity'], $message);
......
......@@ -841,7 +841,7 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $depth = -1) {
}
}
$max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth;
$max_depth = (!isset($max_depth)) ? count($children[$vid]) : $max_depth;
$tree = array();
if ($max_depth > $depth && !empty($children[$vid][$parent])) {
foreach ($children[$vid][$parent] as $child) {
......@@ -1038,7 +1038,7 @@ function taxonomy_implode_tags($tags, $vid = NULL) {
$typed_tags = array();
foreach ($tags as $tag) {
// Extract terms belonging to the vocabulary in question.
if (is_null($vid) || $tag->vid == $vid) {
if (!isset($vid) || $tag->vid == $vid) {
// Make sure we have a completed loaded taxonomy term.
if (isset($tag->name)) {
// Commas and quotes in tag names are special cases, so encode 'em.
......
......@@ -302,7 +302,7 @@ function simpletest_script_init($server_software) {
function simpletest_script_execute_batch() {
global $args;
if (is_null($args['test-id'])) {
if (!isset($args['test-id'])) {
simpletest_script_print_error("--execute-batch should not be called interactively.");
exit;
}
......
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