Commit 9c29ac79 authored by Dries's avatar Dries

- Patch #1059884 by bfroehle, sun, casey: Drop function_exists() for 'callback' functions.

parent f2431f3d
......@@ -4489,10 +4489,8 @@ function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_che
// Libraries, JavaScript and CSS have been added already, as they require
// special handling.
foreach ($elements['#attached'] as $callback => $options) {
if (function_exists($callback)) {
foreach ($elements['#attached'][$callback] as $args) {
call_user_func_array($callback, $args);
}
foreach ($elements['#attached'][$callback] as $args) {
call_user_func_array($callback, $args);
}
}
......@@ -5784,9 +5782,7 @@ function drupal_render(&$elements) {
// element is rendered into the final text.
if (isset($elements['#pre_render'])) {
foreach ($elements['#pre_render'] as $function) {
if (function_exists($function)) {
$elements = $function($elements);
}
$elements = $function($elements);
}
}
......@@ -5830,9 +5826,7 @@ function drupal_render(&$elements) {
// which allows the output'ed text to be filtered.
if (isset($elements['#post_render'])) {
foreach ($elements['#post_render'] as $function) {
if (function_exists($function)) {
$elements['#children'] = $function($elements['#children'], $elements);
}
$elements['#children'] = $function($elements['#children'], $elements);
}
}
......@@ -7668,16 +7662,14 @@ function drupal_get_filetransfer_info() {
$info = array();
foreach (module_implements('filetransfer_info') as $module) {
$function = $module . '_filetransfer_info';
if (function_exists($function)) {
$result = $function();
if (isset($result) && is_array($result)) {
foreach ($result as &$values) {
if (empty($values['file path'])) {
$values['file path'] = drupal_get_path('module', $module);
}
$result = $function();
if (isset($result) && is_array($result)) {
foreach ($result as &$values) {
if (empty($values['file path'])) {
$values['file path'] = drupal_get_path('module', $module);
}
$info = array_merge_recursive($info, $result);
}
$info = array_merge_recursive($info, $result);
}
}
drupal_alter('filetransfer_info', $info);
......
......@@ -784,7 +784,7 @@ function drupal_retrieve_form($form_id, &$form_state) {
// the actual form builder function ($callback) expects. This allows for
// pre-populating a form with common elements for certain forms, such as
// back/next/save buttons in multi-step form wizards. See drupal_build_form().
if (isset($form_state['wrapper_callback']) && function_exists($form_state['wrapper_callback'])) {
if (isset($form_state['wrapper_callback'])) {
$form = call_user_func_array($form_state['wrapper_callback'], $args);
// Put the prepopulated $form into $args.
$args[0] = $form;
......@@ -4391,9 +4391,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'd
// Redirect for processing.
$function = $batch['redirect_callback'];
if (function_exists($function)) {
$function($batch['url'], array('query' => array('op' => 'start', 'id' => $batch['id'])));
}
$function($batch['url'], array('query' => array('op' => 'start', 'id' => $batch['id'])));
}
else {
// Non-progressive execution: bypass the whole progressbar workflow
......
......@@ -632,7 +632,7 @@ function _menu_check_access(&$item, $map) {
if ($callback == 'user_access') {
$item['access'] = (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]);
}
elseif (function_exists($callback)) {
else {
$item['access'] = call_user_func_array($callback, $arguments);
}
}
......@@ -692,7 +692,7 @@ function _menu_item_localize(&$item, $map, $link_translate = FALSE) {
$item['title'] = t($item['title'], menu_unserialize($item['title_arguments'], $map));
}
}
elseif ($callback && function_exists($callback)) {
elseif ($callback) {
if (empty($item['title_arguments'])) {
$item['title'] = $callback($item['title']);
}
......@@ -1750,7 +1750,7 @@ function menu_get_custom_theme($initialize = FALSE) {
// If this returns a valid theme, it will override any theme that was set
// by a hook_custom_theme() implementation above.
$router_item = menu_get_item();
if (!empty($router_item['access']) && !empty($router_item['theme_callback']) && function_exists($router_item['theme_callback'])) {
if (!empty($router_item['access']) && !empty($router_item['theme_callback'])) {
$theme_name = call_user_func_array($router_item['theme_callback'], $router_item['theme_arguments']);
if (drupal_theme_access($theme_name)) {
$custom_theme = $theme_name;
......
......@@ -86,7 +86,7 @@ function token_replace($text, array $data = array(), array $options = array()) {
}
// Optionally alter the list of replacement values.
if (!empty($options['callback']) && function_exists($options['callback'])) {
if (!empty($options['callback'])) {
$function = $options['callback'];
$function($replacements, $data, $options);
}
......
......@@ -1244,7 +1244,7 @@ function book_export_traverse($tree, $visit_func) {
$children = book_export_traverse($data['below'], $visit_func);
}
if (function_exists($visit_func)) {
if (!empty($visit_func)) {
$output .= call_user_func($visit_func, $node, $children);
}
else {
......
......@@ -373,7 +373,7 @@ function entity_uri($entity_type, $entity) {
}
// Invoke the callback to get the URI. If there is no callback, return NULL.
if (isset($uri_callback) && function_exists($uri_callback)) {
if (isset($uri_callback)) {
$uri = $uri_callback($entity);
// Pass the entity data to url() so that alter functions do not need to
// lookup this entity again.
......@@ -403,7 +403,7 @@ function entity_uri($entity_type, $entity) {
function entity_label($entity_type, $entity) {
$label = FALSE;
$info = entity_get_info($entity_type);
if (isset($info['label callback']) && function_exists($info['label callback'])) {
if (isset($info['label callback'])) {
$label = $info['label callback']($entity_type, $entity);
}
elseif (!empty($info['entity keys']['label']) && isset($entity->{$info['entity keys']['label']})) {
......
......@@ -494,9 +494,7 @@ function field_get_default_value($entity_type, $entity, $field, $instance, $lang
$items = array();
if (!empty($instance['default_value_function'])) {
$function = $instance['default_value_function'];
if (function_exists($function)) {
$items = $function($entity_type, $entity, $field, $instance, $langcode);
}
$items = $function($entity_type, $entity, $field, $instance, $langcode);
}
elseif (!empty($instance['default_value'])) {
$items = $instance['default_value'];
......
......@@ -231,7 +231,7 @@ function list_allowed_values($field) {
if (!isset($allowed_values[$field['id']])) {
$function = $field['settings']['allowed_values_function'];
if (!empty($function) && function_exists($function)) {
if (!empty($function)) {
$values = $function($field);
}
else {
......
......@@ -281,7 +281,7 @@ function _field_ui_view_mode_menu_access($entity_type, $bundle, $view_mode, $acc
if ($access_callback == 'user_access') {
return (count($args) == 1) ? user_access($args[0]) : user_access($args[0], $args[1]);
}
elseif (function_exists($access_callback)) {
else {
return call_user_func_array($access_callback, $args);
}
}
......
......@@ -230,7 +230,7 @@ function filter_admin_format_form($form, &$form_state, $format) {
);
foreach ($filter_info as $name => $filter) {
if (isset($filter['settings callback']) && function_exists($filter['settings callback'])) {
if (isset($filter['settings callback'])) {
$function = $filter['settings callback'];
// Pass along stored filter settings and default settings, but also the
// format object and all filters to allow for complex implementations.
......
......@@ -746,7 +746,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE)
// Give filters the chance to escape HTML-like data such as code or formulas.
foreach ($filters as $name => $filter) {
if ($filter->status && isset($filter_info[$name]['prepare callback']) && function_exists($filter_info[$name]['prepare callback'])) {
if ($filter->status && isset($filter_info[$name]['prepare callback'])) {
$function = $filter_info[$name]['prepare callback'];
$text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
}
......@@ -754,7 +754,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE)
// Perform filtering.
foreach ($filters as $name => $filter) {
if ($filter->status && isset($filter_info[$name]['process callback']) && function_exists($filter_info[$name]['process callback'])) {
if ($filter->status && isset($filter_info[$name]['process callback'])) {
$function = $filter_info[$name]['process callback'];
$text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
}
......@@ -1015,7 +1015,7 @@ function _filter_tips($format_id, $long = FALSE) {
$filters = filter_list_format($format->format);
$tips[$format->name] = array();
foreach ($filters as $name => $filter) {
if ($filter->status && isset($filter_info[$name]['tips callback']) && function_exists($filter_info[$name]['tips callback'])) {
if ($filter->status && isset($filter_info[$name]['tips callback'])) {
$tip = $filter_info[$name]['tips callback']($filter, $format, $long);
if (isset($tip)) {
$tips[$format->name][$name] = array('tip' => $tip, 'id' => $name);
......
......@@ -389,9 +389,8 @@ function image_effect_form($form, &$form_state, $style, $effect) {
$form['#tree'] = TRUE;
$form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array();
if (function_exists($effect['form callback'])) {
$form['data'] = call_user_func($effect['form callback'], $effect['data']);
}
$form['data'] = call_user_func($effect['form callback'], $effect['data']);
// Check the URL for a weight, then the image effect, otherwise use default.
$form['weight'] = array(
......
......@@ -1150,10 +1150,7 @@ function image_effect_delete($effect) {
function image_effect_apply($image, $effect) {
module_load_include('inc', 'image', 'image.effects');
$function = $effect['effect callback'];
if (function_exists($function)) {
return $function($image, $effect['data']);
}
return FALSE;
return $function($image, $effect['data']);
}
/**
......
......@@ -304,7 +304,7 @@ function rdf_rdfa_attributes($mapping, $data = NULL) {
case 'property':
$attributes['property'] = $mapping['predicates'];
// Convert $data to a specific format as per the callback function.
if (isset($data) && isset($mapping['callback']) && function_exists($mapping['callback'])) {
if (isset($data) && isset($mapping['callback'])) {
$callback = $mapping['callback'];
$attributes['content'] = $callback($data);
}
......
......@@ -52,7 +52,7 @@ function search_view($module = NULL, $keys = '') {
// the search query URL clean as a whistle.
if (empty($_POST['form_id']) || $_POST['form_id'] != 'search_form') {
$conditions = NULL;
if (isset($info['conditions_callback']) && function_exists($info['conditions_callback'])) {
if (isset($info['conditions_callback'])) {
// Build an optional array of more search conditions.
$conditions = call_user_func($info['conditions_callback'], $keys);
}
......
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