You are here

function cf_error_invalid_variable in Common Functionality 7

Same name and namespace in other branches
  1. 7.2 modules/cf_1x_compatibility/cf_1x_compatibility.module \cf_error_invalid_variable()

Reports variables as invalid to the watchdog system.

Why: Many drupal modules lack validation of parameter arguments. Checking these arguments is important for both integrity and security. Silently failing on these arguments will only hide the problem.

Parameters

array $function_history: An array of function names, ie: array('0' => 'my_function_name').

string $argument_name: The variable name of the argument in question.

string $why: The specific reason for this watchdog report.

array $variables: (optional) Locale safe parameter handling for all text found in the 'why' parameter.

int $severity: (optional) This is passed directly to watchdog and represents the severity of the report.

15 calls to cf_error_invalid_variable()
cf_convert_from_crud in ./cf.module
Converts the passed argument into an array of multiple booleans.
cf_error_empty_string in modules/cf_error/cf_error.module
Reports that a given argument is supposed to be non-empty string but is not.
cf_error_invalid_array in modules/cf_error/cf_error.module
Reports that a given argument is supposed to be an array but is not.
cf_error_invalid_bool in modules/cf_error/cf_error.module
Reports that a given argument is supposed to be an boolean but is not.
cf_error_invalid_callable in modules/cf_error/cf_error.module
Reports if an argument is not a callable function.

... See full list

File

modules/cf_error/cf_error.module, line 177

Code

function cf_error_invalid_variable($function_history, $argument_name, $why, array $variables = array(), $severity = WATCHDOG_ERROR) {
  cf_error_append_history($function_history, __FUNCTION__);
  if ($argument_name == '') {
    cf_error_empty_string($function_history, 'argument_name');
  }
  if (!is_string($why)) {
    $why = "";
  }
  $variables_array = array_merge($variables, array(
    '%argument_name' => $argument_name,
    '%function_history' => print_r($function_history, TRUE),
  ));
  $message = "The argument '%argument_name' is invalid or has a problem, reason: " . $why;
  cf_error_print_message($message, $variables_array, 'bad variable', $severity, $function_history);
}