1 bootstrap.inc watchdog_deprecated_function($type, $func, $link = NULL)

Logs a deprecation warning.

This is a wrapper function for watchdog() to record uses of deprecated functions in Backdrop modules. To prevent an explosion of WATCHDOG_DEPRECATED messages, only the first use of a function in a particular file:line will get a watchdog message.

Parameters

$type: The category to which this message belongs.

$func: The function or method deprecated. Usually, __FUNCTION__ or __METHOD__.

$link: A link to associate with the message.

See also

watchdog()

File

core/includes/bootstrap.inc, line 2218
Functions that need to be loaded on every Backdrop request.

Code

function watchdog_deprecated_function($type, $func, $link = NULL) {
  static $deprecated_calls = array();

  // Return early if not logging deprecation warnings.
  if (!watchdog_severity_enabled(WATCHDOG_DEPRECATED)) {
    return;
  }

  require_once BACKDROP_ROOT . '/core/includes/errors.inc';

  // Get the caller of the deprecated function.
  $trace = debug_backtrace();
  array_shift($trace);
  $caller = _backdrop_get_last_caller($trace);

  $caller_sig = $caller['file'] . ':' . $caller['line'];
  if (array_key_exists($caller_sig, $deprecated_calls)) {
    return;
  }
  $deprecated_calls[$caller_sig] = TRUE;

  // Call watchdog()
  $message = 'The function @original_caller (@file:@line) called deprecated function @function(). It will be removed in the next major release of Backdrop.';
  $variables = array(
    '@function' => $func,
    '@original_caller' => $caller['function'],
    '@file' => basename($caller['file']),
    '@line' => $caller['line'],
  );
  watchdog($type, $message, $variables, WATCHDOG_DEPRECATED, $link);
}