1 bootstrap.inc backdrop_is_background($is_background = NULL)

Stores if Backdrop is currently being executed in the background.

If Backdrop has entered into background mode, it can no longer print anything to the page, because the response has already been returned to the browser. Anything that has been output while in background mode will be silently discarded. Background mode is extremely useful for doing processing that doesn't require output, such as cron job execution or creating cache entries.

Backdrop core uses background mode in two ways:

  • After generating a page (logged-in or anonymous) if cron has not run recently, the page will be returned to the user, and Backdrop will enter background mode to process the cron jobs.
  • If the page cache is turned on, and the "Use background fetch" option is turned on in the performance settings, then Backdrop will serve a cached page even after it has expired. After serving the cached page, Backdrop will enter background mode to generate a new cache entry for the page, which will be delivered to the next user.

Parameters

bool $is_background: May be set to TRUE to indicate entering background mode. Once set, it can not be set back to FALSE.

Return value

bool: TRUE if the request is in background mode. FALSE if in a normal page request and output has not yet started.

File

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

Code

function backdrop_is_background($is_background = NULL) {
  static $static = FALSE;
  if (isset($is_background) && $is_background === TRUE) {
    $static = $is_background;
  }
  return $static;
}