- Patch #40631 by Chris Johnson: is_array() slower than isset() or empty().

4.7.x
Dries Buytaert 2005-12-14 20:10:45 +00:00
parent e53f58fbe0
commit 764f1177ef
21 changed files with 46 additions and 43 deletions

View File

@ -741,7 +741,7 @@ function format_rss_item($title, $link, $description, $args = array()) {
if (is_array($value)) {
if ($value['key']) {
$output .= ' <'. $value['key'];
if (is_array($value['attributes'])) {
if (isset($value['attributes']) && is_array($value['attributes'])) {
$output .= drupal_attributes($value['attributes']);
}

View File

@ -232,7 +232,7 @@ function _db_rewrite_sql($query = '', $primary_table = 'n', $primary_field = 'ni
$distinct = FALSE;
foreach (module_implements('db_rewrite_sql') as $module) {
$result = module_invoke($module, 'db_rewrite_sql', $query, $primary_table, $primary_field, $args);
if (is_array($result)) {
if (isset($result) && is_array($result)) {
if (isset($result['where'])) {
$where[] .= $result['where'];
}

View File

@ -490,7 +490,7 @@ function file_download() {
if ($headers === -1) {
drupal_access_denied();
}
elseif (is_array($headers)) {
elseif (isset($headers) && is_array($headers)) {
file_transfer($file, $headers);
}
}

View File

@ -318,10 +318,11 @@ function _form_builder($form_id, $form) {
* The rendered HTML form.
*/
function form_render(&$elements) {
$content = '';
if (is_array($elements)) {
uasort($elements, "_form_sort");
if (!isset($elements)) {
return NULL;
}
$content = '';
uasort($elements, "_form_sort");
if (!$elements['#children']) {
/* render all the children using a theme function */
@ -380,11 +381,11 @@ function _element_info($type, $refresh = null) {
'#tree' => FALSE,
'#parents' => $parents
);
if ($refresh || !is_array($cache)) {
if ($refresh || !isset($cache)) {
$cache = array();
foreach (module_implements('elements') as $module) {
$elements = module_invoke($module, 'elements');
if (is_array($elements)) {
if (isset($elements) && is_array($elements)) {
$cache = array_merge_recursive($cache, $elements);
}
}

View File

@ -89,7 +89,7 @@ function image_get_info($file) {
$data = @getimagesize($file);
$file_size = @filesize($file);
if (is_array($data)) {
if (isset($data) && is_array($data)) {
$extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
$extension = array_key_exists($data[2], $extensions) ? $extensions[$data[2]] : '';
$details = array('width' => $data[0],

View File

@ -190,7 +190,7 @@ function module_invoke_all() {
foreach (module_implements($hook) as $module) {
$function = $module .'_'. $hook;
$result = call_user_func_array($function, $args);
if (is_array($result)) {
if (isset($result) && is_array($result)) {
$return = array_merge($return, $result);
}
else if (isset($result)) {

View File

@ -599,7 +599,8 @@ function block_list($region) {
// Check the current throttle status and see if block should be displayed
// based on server load.
if (!($block->throttle && (module_invoke('throttle', 'status') > 0))) {
if (is_array($array = module_invoke($block->module, 'block', 'view', $block->delta))) {
$array = module_invoke($block->module, 'block', 'view', $block->delta);
if (isset($array) && is_array($array)) {
foreach ($array as $k => $v) {
$block->$k = $v;
}

View File

@ -599,7 +599,8 @@ function block_list($region) {
// Check the current throttle status and see if block should be displayed
// based on server load.
if (!($block->throttle && (module_invoke('throttle', 'status') > 0))) {
if (is_array($array = module_invoke($block->module, 'block', 'view', $block->delta))) {
$array = module_invoke($block->module, 'block', 'view', $block->delta);
if (isset($array) && is_array($array)) {
foreach ($array as $k => $v) {
$block->$k = $v;
}

View File

@ -1112,7 +1112,7 @@ function theme_comment_admin_overview($form) {
$header = array(NULL, t('Subject'), t('Author'), t('Time'), t('Operations'));
$output = form_render($form['options']);
if (is_array($form['subject'])) {
if (isset($form['subject']) && is_array($form['subject'])) {
foreach (element_children($form['subject']) as $key) {
$row = array();
$row[] = form_render($form['comments'][$key]);
@ -1657,7 +1657,7 @@ function comment_invoke_comment(&$comment, $op) {
foreach (module_implements('comment') as $name) {
$function = $name .'_comment';
$result = $function($comment, $op);
if (is_array($result)) {
if (isset($result) && is_array($result)) {
$return = array_merge($return, $result);
}
else if (isset($result)) {

View File

@ -1112,7 +1112,7 @@ function theme_comment_admin_overview($form) {
$header = array(NULL, t('Subject'), t('Author'), t('Time'), t('Operations'));
$output = form_render($form['options']);
if (is_array($form['subject'])) {
if (isset($form['subject']) && is_array($form['subject'])) {
foreach (element_children($form['subject']) as $key) {
$row = array();
$row[] = form_render($form['comments'][$key]);
@ -1657,7 +1657,7 @@ function comment_invoke_comment(&$comment, $op) {
foreach (module_implements('comment') as $name) {
$function = $name .'_comment';
$result = $function($comment, $op);
if (is_array($result)) {
if (isset($result) && is_array($result)) {
$return = array_merge($return, $result);
}
else if (isset($result)) {

View File

@ -556,7 +556,7 @@ function filter_admin_configure() {
$form = array();
foreach ($list as $filter) {
$form_module = module_invoke($filter->module, 'filter', 'settings', $filter->delta, $format);
if (is_array($form_module)) {
if (isset($form_module) && is_array($form_module)) {
$form = array_merge($form, $form_module);
}
}
@ -613,7 +613,7 @@ function filter_list_all() {
foreach (module_list() as $module) {
$list = module_invoke($module, 'filter', 'list');
if (is_array($list)) {
if (isset($list) && is_array($list)) {
foreach ($list as $delta => $name) {
$filters[$module .'/'. $delta] = (object)array('module' => $module, 'delta' => $delta, 'name' => $name);
}
@ -655,7 +655,7 @@ function filter_list_format($format) {
$result = db_query("SELECT * FROM {filters} WHERE format = %d ORDER BY weight ASC", $format);
while ($filter = db_fetch_object($result)) {
$list = module_invoke($filter->module, 'filter', 'list');
if (is_array($list) && isset($list[$filter->delta])) {
if (isset($list) && is_array($list) && isset($list[$filter->delta])) {
$filter->name = $list[$filter->delta];
$filters[$format][$filter->module .'/'. $filter->delta] = $filter;
}

View File

@ -556,7 +556,7 @@ function filter_admin_configure() {
$form = array();
foreach ($list as $filter) {
$form_module = module_invoke($filter->module, 'filter', 'settings', $filter->delta, $format);
if (is_array($form_module)) {
if (isset($form_module) && is_array($form_module)) {
$form = array_merge($form, $form_module);
}
}
@ -613,7 +613,7 @@ function filter_list_all() {
foreach (module_list() as $module) {
$list = module_invoke($module, 'filter', 'list');
if (is_array($list)) {
if (isset($list) && is_array($list)) {
foreach ($list as $delta => $name) {
$filters[$module .'/'. $delta] = (object)array('module' => $module, 'delta' => $delta, 'name' => $name);
}
@ -655,7 +655,7 @@ function filter_list_format($format) {
$result = db_query("SELECT * FROM {filters} WHERE format = %d ORDER BY weight ASC", $format);
while ($filter = db_fetch_object($result)) {
$list = module_invoke($filter->module, 'filter', 'list');
if (is_array($list) && isset($list[$filter->delta])) {
if (isset($list) && is_array($list) && isset($list[$filter->delta])) {
$filter->name = $list[$filter->delta];
$filters[$format][$filter->module .'/'. $filter->delta] = $filter;
}

View File

@ -315,7 +315,7 @@ function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
foreach (module_implements('nodeapi') as $name) {
$function = $name .'_nodeapi';
$result = $function($node, $op, $a3, $a4);
if (is_array($result)) {
if (isset($result) && is_array($result)) {
$return = array_merge($return, $result);
}
else if (isset($result)) {
@ -751,10 +751,10 @@ function node_search($op = 'search', $keys = null) {
case 'post':
// Insert extra restrictions into the search keywords string.
$edit = &$_POST['edit'];
if (is_array($edit['type'])) {
if (isset($edit['type']) && is_array($edit['type'])) {
$keys = search_query_insert($keys, 'type', implode(',', array_keys($edit['type'])));
}
if (is_array($edit['category'])) {
if (isset($edit['category']) && is_array($edit['category'])) {
$keys = search_query_insert($keys, 'category', implode(',', $edit['category']));
}
if ($edit['or'] != '') {
@ -1172,7 +1172,7 @@ function theme_node_admin_nodes($form) {
$header = array(NULL, t('Title'), t('Type'), t('Author'), t('Status'), t('Operations'));
$output .= form_render($form['options']);
if (is_array($form['title'])) {
if (isset($form['title']) && is_array($form['title'])) {
foreach (element_children($form['title']) as $key) {
$row = array();
$row[] = form_render($form['nodes'][$key]);

View File

@ -315,7 +315,7 @@ function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
foreach (module_implements('nodeapi') as $name) {
$function = $name .'_nodeapi';
$result = $function($node, $op, $a3, $a4);
if (is_array($result)) {
if (isset($result) && is_array($result)) {
$return = array_merge($return, $result);
}
else if (isset($result)) {
@ -751,10 +751,10 @@ function node_search($op = 'search', $keys = null) {
case 'post':
// Insert extra restrictions into the search keywords string.
$edit = &$_POST['edit'];
if (is_array($edit['type'])) {
if (isset($edit['type']) && is_array($edit['type'])) {
$keys = search_query_insert($keys, 'type', implode(',', array_keys($edit['type'])));
}
if (is_array($edit['category'])) {
if (isset($edit['category']) && is_array($edit['category'])) {
$keys = search_query_insert($keys, 'category', implode(',', $edit['category']));
}
if ($edit['or'] != '') {
@ -1172,7 +1172,7 @@ function theme_node_admin_nodes($form) {
$header = array(NULL, t('Title'), t('Type'), t('Author'), t('Status'), t('Operations'));
$output .= form_render($form['options']);
if (is_array($form['title'])) {
if (isset($form['title']) && is_array($form['title'])) {
foreach (element_children($form['title']) as $key) {
$row = array();
$row[] = form_render($form['nodes'][$key]);

View File

@ -975,7 +975,7 @@ function search_form($action = '', $keys = '', $type = null, $prompt = null) {
$form['basic']['inline']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
$form_module = module_invoke($type, 'search', 'form', $keys);
if (is_array($form_module)) {
if (isset($form_module) && is_array($form_module)) {
$form = array_merge($form, $form_module);
}
@ -991,7 +991,7 @@ function search_data($keys = NULL, $type = 'node') {
if (isset($keys)) {
if (module_hook($type, 'search')) {
$results = module_invoke($type, 'search', 'search', $keys);
if (is_array($results) && count($results)) {
if (isset($results) && is_array($results) && count($results)) {
$output .= '<dl class="search-results">';
foreach ($results as $entry) {
$output .= theme('search_item', $entry, $type);

View File

@ -975,7 +975,7 @@ function search_form($action = '', $keys = '', $type = null, $prompt = null) {
$form['basic']['inline']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
$form_module = module_invoke($type, 'search', 'form', $keys);
if (is_array($form_module)) {
if (isset($form_module) && is_array($form_module)) {
$form = array_merge($form, $form_module);
}
@ -991,7 +991,7 @@ function search_data($keys = NULL, $type = 'node') {
if (isset($keys)) {
if (module_hook($type, 'search')) {
$results = module_invoke($type, 'search', 'search', $keys);
if (is_array($results) && count($results)) {
if (isset($results) && is_array($results) && count($results)) {
$output .= '<dl class="search-results">';
foreach ($results as $entry) {
$output .= theme('search_item', $entry, $type);

View File

@ -596,7 +596,7 @@ function taxonomy_node_save($nid, $terms) {
// Free tagging vocabularies do not send their tids in the form,
// so we'll detect them here and process them independently.
if ($terms['tags']) {
if (isset($terms['tags'])) {
$typed_input = $terms['tags'];
unset($terms['tags']);

View File

@ -596,7 +596,7 @@ function taxonomy_node_save($nid, $terms) {
// Free tagging vocabularies do not send their tids in the form,
// so we'll detect them here and process them independently.
if ($terms['tags']) {
if (isset($terms['tags'])) {
$typed_input = $terms['tags'];
unset($terms['tags']);

View File

@ -18,8 +18,8 @@
<?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?>
</td>
<td id="menu">
<?php if ($secondary_links) { ?><div id="secondary"><?php print theme('links', $secondary_links) ?></div><?php } ?>
<?php if ($primary_links) { ?><div id="primary"><?php print theme('links', $primary_links) ?></div><?php } ?>
<?php if (isset($secondary_links)) { ?><div id="secondary"><?php print theme('links', $secondary_links) ?></div><?php } ?>
<?php if (isset($primary_links)) { ?><div id="primary"><?php print theme('links', $primary_links) ?></div><?php } ?>
<?php print $search_box ?>
</td>
</tr>

View File

@ -55,12 +55,12 @@ function chameleon_page($content) {
$primary_links = theme('links', menu_primary_links());
$secondary_links = theme('links', menu_secondary_links());
if ($primary_links || $secondary_links) {
if (isset($primary_links) || isset($secondary_links)) {
$output .= ' <div class="navlinks">';
if ($primary_links) {
if (isset($primary_links)) {
$output .= '<div class="primary">'. $primary_links .'</div>';
}
if ($secondary_links) {
if (($secondary_links)) {
$output .= '<div class="secondary">'. $secondary_links .'</div>';
}
$output .= " </div>\n";

View File

@ -102,12 +102,12 @@
<table id="footer-menu" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center" valign="middle">
<?php if (is_array($primary_links)) : ?>
<?php if (isset($primary_links)) : ?>
<div class="primary-links">
<?php print theme('links', $primary_links) ?>
</div>
<?php endif; ?>
<?php if (is_array($secondary_links)) : ?>
<?php if (isset($secondary_links)) : ?>
<div class="secondary-links">
<?php print theme('links', $secondary_links) ?>
</div>