Commit 1d0f6479 authored by Dries's avatar Dries

- Patch #839556 by jrchamp, dmitrig01: remove pointless usage of array_key_exists().

parent 0344a78d
......@@ -278,7 +278,7 @@ function actions_synchronize($delete_orphans = FALSE) {
// user adds the action.
if (!$array['configurable']) {
// If we already have an action ID for this action, no need to assign aid.
if (array_key_exists($callback, $actions_in_db)) {
if (isset($actions_in_db[$callback])) {
unset($actions_in_db[$callback]);
}
else {
......
......@@ -469,9 +469,7 @@ public function changeField($table, $field, $field_new, $spec, $new_keys = array
throw new DatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
}
if (!array_key_exists('size', $spec)) {
$spec['size'] = 'normal';
}
$spec += array('size' => 'normal');
// Map type definition to the PostgreSQL type.
if (!isset($spec['pgsql_type'])) {
......
......@@ -80,7 +80,7 @@ protected function getSort() {
// User has not specified a sort. Use default if specified; otherwise use "asc".
else {
foreach ($this->header as $header) {
if (is_array($header) && array_key_exists('sort', $header)) {
if (isset($header['sort'])) {
return $header['sort'];
}
}
......@@ -279,7 +279,7 @@ function tablesort_get_sort($headers) {
// User has not specified a sort. Use default if specified; otherwise use "asc".
else {
foreach ($headers as $header) {
if (is_array($header) && array_key_exists('sort', $header)) {
if (isset($header['sort'])) {
return $header['sort'];
}
}
......
......@@ -402,7 +402,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
// that themes don't need to specify this information, since the module
// that registered the theme hook already has.
foreach (array('variables', 'render element', 'pattern', 'base hook') as $key) {
if (!array_key_exists($key, $info) && isset($cache[$hook][$key])) {
if (!isset($info[$key]) && isset($cache[$hook][$key])) {
$result[$hook][$key] = $cache[$hook][$key];
}
}
......
......@@ -607,7 +607,7 @@ function block_theme_initialize($theme) {
$result = db_query("SELECT * FROM {block} WHERE theme = :theme", array(':theme' => $default_theme), array('fetch' => PDO::FETCH_ASSOC));
foreach ($result as $block) {
// If the region isn't supported by the theme, assign the block to the theme's default region.
if ($block['status'] && !array_key_exists($block['region'], $regions)) {
if ($block['status'] && !isset($regions[$block['region']])) {
$block['region'] = system_default_region($theme);
}
$block['theme'] = $theme;
......
......@@ -2287,7 +2287,8 @@ function theme_comment_post_forbidden($variables) {
if (!isset($authenticated_post_comments)) {
// We only output a link if we are certain that users will get permission
// to post comments by logging in.
$authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'skip comment approval'));
$comment_roles = user_roles(TRUE, 'post comments') + user_roles(TRUE, 'skip comment approval');
$authenticated_post_comments = isset($comment_roles[DRUPAL_AUTHENTICATED_RID]);
}
if ($authenticated_post_comments) {
......
......@@ -261,7 +261,7 @@ function list_field_validate($entity_type, $entity, $field, $instance, $langcode
$allowed_values = list_allowed_values($field);
foreach ($items as $delta => $item) {
if (!empty($item['value'])) {
if (count($allowed_values) && !array_key_exists($item['value'], $allowed_values)) {
if (!empty($allowed_values) && !isset($allowed_values[$item['value']])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'list_illegal_value',
'message' => t('%name: illegal value.', array('%name' => t($instance['label']))),
......
......@@ -54,7 +54,7 @@ function field_ui_inactive_message($entity_type, $bundle) {
$list[] = t('%field (@field_name) field requires the %widget_type widget provided by %widget_module module', array(
'%field' => $instance['label'],
'@field_name' => $instance['field_name'],
'%widget_type' => array_key_exists($instance['widget']['type'], $widget_types) ? $widget_types[$instance['widget']['type']]['label'] : $instance['widget']['type'],
'%widget_type' => isset($widget_types[$instance['widget']['type']]) ? $widget_types[$instance['widget']['type']]['label'] : $instance['widget']['type'],
'%widget_module' => $instance['widget']['module'],
));
}
......
......@@ -1301,14 +1301,12 @@ function _filter_html_tips($filter, $format, $long = FALSE) {
$header = array(t('Tag Description'), t('You Type'), t('You Get'));
preg_match_all('/<([a-z0-9]+)[^a-z0-9]/i', $allowed_html, $out);
foreach ($out[1] as $tag) {
if (array_key_exists($tag, $tips)) {
if ($tips[$tag]) {
$rows[] = array(
array('data' => $tips[$tag][0], 'class' => array('description')),
array('data' => '<code>' . check_plain($tips[$tag][1]) . '</code>', 'class' => array('type')),
array('data' => $tips[$tag][1], 'class' => array('get'))
);
}
if (!empty($tips[$tag])) {
$rows[] = array(
array('data' => $tips[$tag][0], 'class' => array('description')),
array('data' => '<code>' . check_plain($tips[$tag][1]) . '</code>', 'class' => array('type')),
array('data' => $tips[$tag][1], 'class' => array('get'))
);
}
else {
$rows[] = array(
......
......@@ -501,7 +501,7 @@ function _openid_dh_rand($stop) {
// Used as the key for the duplicate cache
$rbytes = _openid_dh_long_to_binary($stop);
if (array_key_exists($rbytes, $duplicate_cache)) {
if (isset($duplicate_cache[$rbytes])) {
list($duplicate, $nbytes) = $duplicate_cache[$rbytes];
}
else {
......
......@@ -932,7 +932,7 @@ function openid_verify_assertion_return_url($service, $response) {
// contains a number of other parameters added by the OpenID Provider.
parse_str(isset($return_to_parts['query']) ? $return_to_parts['query'] : '', $return_to_query_parameters);
foreach ($return_to_query_parameters as $name => $value) {
if (!array_key_exists($name, $_GET) || $_GET[$name] != $value) {
if (!isset($_GET[$name]) || $_GET[$name] != $value) {
return FALSE;
}
}
......
......@@ -126,7 +126,7 @@ function theme_profile_admin_overview($variables) {
$category_number = 0;
foreach (element_children($form) as $key) {
// Don't take form control structures.
if (array_key_exists('category', $form[$key])) {
if (isset($form[$key]['category'])) {
$field = &$form[$key];
$category = $field['category']['#default_value'];
......
......@@ -351,7 +351,7 @@ function image_gd_get_info(stdClass $image) {
if (isset($data) && is_array($data)) {
$extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
$extension = array_key_exists($data[2], $extensions) ? $extensions[$data[2]] : '';
$extension = isset($extensions[$data[2]]) ? $extensions[$data[2]] : '';
$details = array(
'width' => $data[0],
'height' => $data[1],
......
......@@ -2645,7 +2645,7 @@ function hook_file_url_alter(&$uri) {
// Serve files with one of the CDN extensions from CDN 1, all others from
// CDN 2.
$pathinfo = pathinfo($path);
if (array_key_exists('extension', $pathinfo) && in_array($pathinfo['extension'], $cdn_extensions)) {
if (isset($pathinfo['extension']) && in_array($pathinfo['extension'], $cdn_extensions)) {
$uri = $cdn1 . '/' . $path;
}
else {
......
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