From 1d0f6479da4cdbd14b747ead6cb934a769a9579d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 28 Oct 2010 02:27:09 +0000 Subject: - Patch #839556 by jrchamp, dmitrig01: remove pointless usage of array_key_exists(). --- includes/actions.inc | 2 +- includes/database/pgsql/schema.inc | 4 +--- includes/tablesort.inc | 4 ++-- includes/theme.inc | 2 +- modules/block/block.module | 2 +- modules/comment/comment.module | 3 ++- modules/field/modules/list/list.module | 2 +- modules/field_ui/field_ui.admin.inc | 2 +- modules/filter/filter.module | 14 ++++++-------- modules/openid/openid.inc | 2 +- modules/openid/openid.module | 2 +- modules/profile/profile.admin.inc | 2 +- modules/system/image.gd.inc | 2 +- modules/system/system.api.php | 2 +- 14 files changed, 21 insertions(+), 24 deletions(-) diff --git a/includes/actions.inc b/includes/actions.inc index 8ee7d5129..fa1f7d386 100644 --- a/includes/actions.inc +++ b/includes/actions.inc @@ -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 { diff --git a/includes/database/pgsql/schema.inc b/includes/database/pgsql/schema.inc index 2ad720ed7..1443bc5c0 100644 --- a/includes/database/pgsql/schema.inc +++ b/includes/database/pgsql/schema.inc @@ -469,9 +469,7 @@ class DatabaseSchema_pgsql extends DatabaseSchema { 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'])) { diff --git a/includes/tablesort.inc b/includes/tablesort.inc index 960bd2f0d..afa5a6979 100644 --- a/includes/tablesort.inc +++ b/includes/tablesort.inc @@ -80,7 +80,7 @@ class TableSort extends SelectQueryExtender { // 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']; } } diff --git a/includes/theme.inc b/includes/theme.inc index 6c7a779d9..fb7038393 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -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]; } } diff --git a/modules/block/block.module b/modules/block/block.module index 3a0be2520..7f0f21070 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -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; diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 52549f974..6b6dedb65 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -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) { diff --git a/modules/field/modules/list/list.module b/modules/field/modules/list/list.module index 3ad913e58..7addd362d 100644 --- a/modules/field/modules/list/list.module +++ b/modules/field/modules/list/list.module @@ -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']))), diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc index c88a51251..de77b9175 100644 --- a/modules/field_ui/field_ui.admin.inc +++ b/modules/field_ui/field_ui.admin.inc @@ -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'], )); } diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 617987421..5eb007fff 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.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' => '' . check_plain($tips[$tag][1]) . '', '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' => '' . check_plain($tips[$tag][1]) . '', 'class' => array('type')), + array('data' => $tips[$tag][1], 'class' => array('get')) + ); } else { $rows[] = array( diff --git a/modules/openid/openid.inc b/modules/openid/openid.inc index 5a9326905..48af76669 100644 --- a/modules/openid/openid.inc +++ b/modules/openid/openid.inc @@ -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 { diff --git a/modules/openid/openid.module b/modules/openid/openid.module index 7e7ebfd05..3e1b2c96b 100644 --- a/modules/openid/openid.module +++ b/modules/openid/openid.module @@ -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; } } diff --git a/modules/profile/profile.admin.inc b/modules/profile/profile.admin.inc index 864e847e0..9c20d3239 100644 --- a/modules/profile/profile.admin.inc +++ b/modules/profile/profile.admin.inc @@ -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']; diff --git a/modules/system/image.gd.inc b/modules/system/image.gd.inc index 2f7a89fce..b10595f47 100644 --- a/modules/system/image.gd.inc +++ b/modules/system/image.gd.inc @@ -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], diff --git a/modules/system/system.api.php b/modules/system/system.api.php index 262f53757..11780eec7 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -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 { -- cgit v1.2.3