1.16.x bootstrap.inc watchdog_deprecated_function($type, $func, $link = NULL)
1.18.x bootstrap.inc watchdog_deprecated_function($type, $func, $link = NULL)
1.17.x 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.


$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



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


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)) {

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

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

  $caller_sig = $caller['file'] . ':' . $caller['line'];
  if (array_key_exists($caller_sig, $deprecated_calls)) {
  $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);