diff options
Diffstat (limited to 'includes/bootstrap.inc')
-rw-r--r-- | includes/bootstrap.inc | 284 |
1 files changed, 166 insertions, 118 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 292b8bb87..c32c05d5f 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -8,7 +8,7 @@ /** * The current system version. */ -define('VERSION', '7.11'); +define('VERSION', '7.12'); /** * Core API compatibility. @@ -43,9 +43,9 @@ define('CACHE_TEMPORARY', -1); * Logging severity levels as defined in RFC 3164. * * The WATCHDOG_* constant definitions correspond to the logging severity levels - * defined in RFC 3164, section 4.1.1. PHP supplies predefined LOG_* constants + * defined in RFC 3164, section 4.1.1. PHP supplies predefined LOG_* constants * for use in the syslog() function, but their values on Windows builds do not - * correspond to RFC 3164. The associated PHP bug report was closed with the + * correspond to RFC 3164. The associated PHP bug report was closed with the * comment, "And it's also not a bug, as Windows just have less log levels," * and "So the behavior you're seeing is perfectly normal." * @@ -137,8 +137,7 @@ define('DRUPAL_BOOTSTRAP_PAGE_HEADER', 5); define('DRUPAL_BOOTSTRAP_LANGUAGE', 6); /** - * Final bootstrap phase: Drupal is fully loaded; validate and fix - * input data. + * Final bootstrap phase: Drupal is fully loaded; validate and fix input data. */ define('DRUPAL_BOOTSTRAP_FULL', 7); @@ -153,8 +152,9 @@ define('DRUPAL_ANONYMOUS_RID', 1); define('DRUPAL_AUTHENTICATED_RID', 2); /** - * The number of bytes in a kilobyte. For more information, visit - * http://en.wikipedia.org/wiki/Kilobyte. + * The number of bytes in a kilobyte. + * + * For more information, visit http://en.wikipedia.org/wiki/Kilobyte. */ define('DRUPAL_KILOBYTE', 1024); @@ -191,10 +191,14 @@ define('LANGUAGE_LTR', 0); define('LANGUAGE_RTL', 1); /** - * For convenience, define a short form of the request time global. + * Time of the current request in seconds elapsed since the Unix Epoch. + * + * This differs from $_SERVER['REQUEST_TIME'], which is stored as a float + * since PHP 5.4.0. Float timestamps confuse most PHP functions + * (including date_create()). * - * REQUEST_TIME is a float with microseconds since PHP 5.4.0, but float - * timestamps confuses most of the PHP functions (including date_create()). + * @see http://php.net/manual/reserved.variables.server.php + * @see http://php.net/manual/function.time.php */ define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']); @@ -285,12 +289,12 @@ abstract class DrupalCacheArray implements ArrayAccess { /** * A cid to pass to cache_set() and cache_get(). */ - private $cid; + protected $cid; /** * A bin to pass to cache_set() and cache_get(). */ - private $bin; + protected $bin; /** * An array of keys to add to the cache at the end of the request. @@ -303,7 +307,7 @@ abstract class DrupalCacheArray implements ArrayAccess { protected $storage = array(); /** - * Constructor. + * Constructs a DrupalCacheArray object. * * @param $cid * The cid for the array being cached. @@ -319,10 +323,16 @@ abstract class DrupalCacheArray implements ArrayAccess { } } + /** + * Implements ArrayAccess::offsetExists(). + */ public function offsetExists($offset) { return $this->offsetGet($offset) !== NULL; } + /** + * Implements ArrayAccess::offsetGet(). + */ public function offsetGet($offset) { if (isset($this->storage[$offset]) || array_key_exists($offset, $this->storage)) { return $this->storage[$offset]; @@ -332,10 +342,16 @@ abstract class DrupalCacheArray implements ArrayAccess { } } + /** + * Implements ArrayAccess::offsetSet(). + */ public function offsetSet($offset, $value) { $this->storage[$offset] = $value; } + /** + * Implements ArrayAccess::offsetUnset(). + */ public function offsetUnset($offset) { unset($this->storage[$offset]); } @@ -375,32 +391,31 @@ abstract class DrupalCacheArray implements ArrayAccess { abstract protected function resolveCacheMiss($offset); /** - * Immediately write a value to the persistent cache. + * Writes a value to the persistent cache immediately. * - * @param $cid - * The cache ID. - * @param $bin - * The cache bin. * @param $data * The data to write to the persistent cache. * @param $lock * Whether to acquire a lock before writing to cache. */ - protected function set($cid, $data, $bin, $lock = TRUE) { + protected function set($data, $lock = TRUE) { // Lock cache writes to help avoid stampedes. // To implement locking for cache misses, override __construct(). - $lock_name = $cid . ':' . $bin; + $lock_name = $this->cid . ':' . $this->bin; if (!$lock || lock_acquire($lock_name)) { - if ($cached = cache_get($cid, $bin)) { + if ($cached = cache_get($this->cid, $this->bin)) { $data = $cached->data + $data; } - cache_set($cid, $data, $bin); + cache_set($this->cid, $data, $this->bin); if ($lock) { lock_release($lock_name); } } } + /** + * Destructs the DrupalCacheArray object. + */ public function __destruct() { $data = array(); foreach ($this->keysToPersist as $offset => $persist) { @@ -409,14 +424,16 @@ abstract class DrupalCacheArray implements ArrayAccess { } } if (!empty($data)) { - $this->set($this->cid, $data, $this->bin); + $this->set($data); } } } /** - * Start the timer with the specified name. If you start and stop the same - * timer multiple times, the measured intervals will be accumulated. + * Starts the timer with the specified name. + * + * If you start and stop the same timer multiple times, the measured intervals + * will be accumulated. * * @param $name * The name of the timer. @@ -429,7 +446,7 @@ function timer_start($name) { } /** - * Read the current timer value without stopping the timer. + * Reads the current timer value without stopping the timer. * * @param $name * The name of the timer. @@ -453,7 +470,7 @@ function timer_read($name) { } /** - * Stop the timer with the specified name. + * Stops the timer with the specified name. * * @param $name * The name of the timer. @@ -578,7 +595,7 @@ function conf_path($require_settings = TRUE, $reset = FALSE) { } /** - * Set appropriate server variables needed for command line scripts to work. + * Sets appropriate server variables needed for command line scripts to work. * * This function can be called by command line scripts before bootstrapping * Drupal, to ensure that the page loads with the desired server parameters. @@ -640,7 +657,7 @@ function drupal_override_server_variables($variables = array()) { } /** - * Initialize PHP environment. + * Initializes the PHP environment. */ function drupal_environment_initialize() { if (!isset($_SERVER['HTTP_REFERER'])) { @@ -699,7 +716,7 @@ function drupal_environment_initialize() { } /** - * Validate that a hostname (for example $_SERVER['HTTP_HOST']) is safe. + * Validates that a hostname (for example $_SERVER['HTTP_HOST']) is safe. * * @return * TRUE if only containing valid characters, or FALSE otherwise. @@ -709,8 +726,7 @@ function drupal_valid_http_host($host) { } /** - * Loads the configuration and sets the base URL, cookie domain, and - * session name correctly. + * Sets the base URL, cookie domain, and session name from configuration. */ function drupal_settings_initialize() { global $base_url, $base_path, $base_root; @@ -796,9 +812,10 @@ function drupal_settings_initialize() { } /** - * Returns and optionally sets the filename for a system item (module, - * theme, etc.). The filename, whether provided, cached, or retrieved - * from the database, is only returned if the file exists. + * Returns and optionally sets the filename for a system resource. + * + * The filename, whether provided, cached, or retrieved from the database, is + * only returned if the file exists. * * This function plays a key role in allowing Drupal's resources (modules * and themes) to be located in different places depending on a site's @@ -828,6 +845,11 @@ function drupal_get_filename($type, $name, $filename = NULL) { // drupal_static(). static $files = array(), $dirs = array(); + // Profiles are a special case: they have a fixed location and naming. + if ($type == 'profile') { + $profile_filename = "profiles/$name/$name.profile"; + $files[$type][$name] = file_exists($profile_filename) ? $profile_filename : FALSE; + } if (!isset($files[$type])) { $files[$type] = array(); } @@ -895,11 +917,11 @@ function drupal_get_filename($type, $name, $filename = NULL) { } /** - * Load the persistent variable table. + * Loads the persistent variable table. * * The variable table is composed of values that have been saved in the table - * with variable_set() as well as those explicitly specified in the configuration - * file. + * with variable_set() as well as those explicitly specified in the + * configuration file. */ function variable_initialize($conf = array()) { // NOTE: caching the variables improves performance by 20% when serving @@ -1006,7 +1028,7 @@ function variable_del($name) { } /** - * Retrieve the current page from the cache. + * Retrieves the current page from the cache. * * Note: we do not serve cached pages to authenticated users, or to anonymous * users when $_SESSION is non-empty. $_SESSION may contain status messages @@ -1038,7 +1060,7 @@ function drupal_page_get_cache($check_only = FALSE) { } /** - * Determine the cacheability of the current page. + * Determines the cacheability of the current page. * * @param $allow_caching * Set to FALSE if you want to prevent this page to get cached. @@ -1057,7 +1079,7 @@ function drupal_page_is_cacheable($allow_caching = NULL) { } /** - * Invoke a bootstrap hook in all bootstrap modules that implement it. + * Invokes a bootstrap hook in all bootstrap modules that implement it. * * @param $hook * The name of the bootstrap hook to invoke. @@ -1079,8 +1101,9 @@ function bootstrap_invoke_all($hook) { } /** - * Includes a file with the provided type and name. This prevents - * including a theme, engine, module, etc., more than once. + * Includes a file with the provided type and name. + * + * This prevents including a theme, engine, module, etc., more than once. * * @param $type * The type of item to load (i.e. theme, theme_engine, module). @@ -1112,7 +1135,7 @@ function drupal_load($type, $name) { } /** - * Set an HTTP response header for the current page. + * Sets an HTTP response header for the current page. * * Note: When sending a Content-Type header, always include a 'charset' type, * too. This is necessary to avoid security bugs (e.g. UTF-7 XSS). @@ -1148,11 +1171,12 @@ function drupal_add_http_header($name, $value, $append = FALSE) { } /** - * Get the HTTP response headers for the current page. + * Gets the HTTP response headers for the current page. * * @param $name * An HTTP header name. If omitted, all headers are returned as name/value * pairs. If an array value is FALSE, the header has been unset. + * * @return * A string containing the header value, or FALSE if the header has been set, * or NULL if the header has not been set. @@ -1169,6 +1193,8 @@ function drupal_get_http_header($name = NULL) { } /** + * Sets the preferred name for the HTTP header. + * * Header names are case-insensitive, but for maximum compatibility they should * follow "common form" (see RFC 2617, section 4.2). */ @@ -1182,9 +1208,10 @@ function _drupal_set_preferred_header_name($name = NULL) { } /** - * Send the HTTP response headers previously set using drupal_add_http_header(). - * Add default headers, unless they have been replaced or unset using - * drupal_add_http_header(). + * Sends the HTTP response headers that were previously set, adding defaults. + * + * Headers are set in drupal_add_http_header(). Default headers are not set + * if they have been replaced or unset using drupal_add_http_header(). * * @param $default_headers * An array of headers as name/value pairs. @@ -1219,7 +1246,7 @@ function drupal_send_headers($default_headers = array(), $only_default = FALSE) } /** - * Set HTTP headers in preparation for a page response. + * Sets HTTP headers in preparation for a page response. * * Authenticated users are always given a 'no-cache' header, and will fetch a * fresh page on every request. This prevents authenticated users from seeing @@ -1262,7 +1289,7 @@ function drupal_page_header() { } /** - * Set HTTP headers in preparation for a cached page response. + * Sets HTTP headers in preparation for a cached page response. * * The headers allow as much as possible in proxies and browsers without any * particular knowledge about the pages. Modules can override these headers @@ -1365,7 +1392,7 @@ function drupal_serve_page_from_cache(stdClass $cache) { } /** - * Define the critical hooks that force modules to always be loaded. + * Defines the critical hooks that force modules to always be loaded. */ function bootstrap_hooks() { return array('boot', 'exit', 'watchdog', 'language_init'); @@ -1418,10 +1445,10 @@ function drupal_unpack($obj, $field = 'data') { * $text = t("@name's blog", array('@name' => format_username($account))); * @endcode * Basically, you can put variables like @name into your string, and t() will - * substitute their sanitized values at translation time (see $args below or - * the Localization API pages referenced above for details). Translators can - * then rearrange the string as necessary for the language (e.g., in Spanish, - * it might be "blog de @name"). + * substitute their sanitized values at translation time. (See the + * Localization API pages referenced above and the documentation of + * format_string() for details.) Translators can then rearrange the string as + * necessary for the language (e.g., in Spanish, it might be "blog de @name"). * * During the Drupal installation phase, some resources used by t() wil not be * available to code that needs localization. See st() and get_t() for @@ -1430,8 +1457,9 @@ function drupal_unpack($obj, $field = 'data') { * @param $string * A string containing the English string to translate. * @param $args - * An associative array of replacements to make after translation. - * See format_string(). + * An associative array of replacements to make after translation. Based + * on the first character of the key, the value is escaped and/or themed. + * See format_string() for details. * @param $options * An associative array of additional options, with the following elements: * - 'langcode' (defaults to the current language): The language code to @@ -1444,6 +1472,7 @@ function drupal_unpack($obj, $field = 'data') { * * @see st() * @see get_t() + * @see format_string() * @ingroup sanitization */ function t($string, array $args = array(), array $options = array()) { @@ -1482,7 +1511,7 @@ function t($string, array $args = array(), array $options = array()) { } /** - * Replace placeholders with sanitized values in a string. + * Replaces placeholders with sanitized values in a string. * * @param $string * A string containing placeholders. @@ -1524,7 +1553,7 @@ function format_string($string, array $args = array()) { } /** - * Encode special characters in a plain-text string for display as HTML. + * Encodes special characters in a plain-text string for display as HTML. * * Also validates strings as UTF-8 to prevent cross site scripting attacks on * Internet Explorer 6. @@ -1563,6 +1592,7 @@ function check_plain($text) { * * @param $text * The text to check. + * * @return * TRUE if the text is valid UTF-8, FALSE if not. */ @@ -1604,7 +1634,7 @@ function request_uri() { } /** - * Log an exception. + * Logs an exception. * * This is a wrapper function for watchdog() which automatically decodes an * exception. @@ -1645,7 +1675,7 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia } /** - * Log a system message. + * Logs a system message. * * @param $type * The category to which this message belongs. Can be any string, but the @@ -1705,7 +1735,7 @@ function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NO } /** - * Set a message which reflects the status of the performed operation. + * Sets a message which reflects the status of the performed operation. * * If the function is called with no arguments, this function returns all set * messages without clearing them. @@ -1741,12 +1771,13 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE) { } /** - * Return all messages that have been set. + * Returns all messages that have been set. * * @param $type * (optional) Only return messages of this type. * @param $clear_queue * (optional) Set to FALSE if you do not want to clear the messages queue + * * @return * An associative array, the key is the message type, the value an array * of messages. If the $type parameter is passed, you get only that type, @@ -1774,7 +1805,9 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) { } /** - * Get the title of the current page, for display on the page and in the title bar. + * Gets the title of the current page. + * + * The title is displayed on the page and in the title bar. * * @return * The current page's title. @@ -1791,7 +1824,9 @@ function drupal_get_title() { } /** - * Set the title of the current page, for display on the page and in the title bar. + * Sets the title of the current page. + * + * The title is displayed on the page and in the title bar. * * @param $title * Optional string value to assign to the page title; or if set to NULL @@ -1816,7 +1851,7 @@ function drupal_set_title($title = NULL, $output = CHECK_PLAIN) { } /** - * Check to see if an IP address has been blocked. + * Checks to see if an IP address has been blocked. * * Blocked IP addresses are stored in the database by default. However for * performance reasons we allow an override in settings.php. This allows us @@ -1825,6 +1860,7 @@ function drupal_set_title($title = NULL, $output = CHECK_PLAIN) { * * @param $ip * IP address to check. + * * @return bool * TRUE if access is denied, FALSE if access is allowed. */ @@ -1850,7 +1886,7 @@ function drupal_is_denied($ip) { } /** - * Handle denied users. + * Handles denied users. * * @param $ip * IP address to check. Prints a message and exits if access is denied. @@ -1869,7 +1905,8 @@ function drupal_block_denied($ip) { * * This function is better than simply calling mt_rand() or any other built-in * PHP function because it can return a long string of bytes (compared to < 4 - * bytes normally from mt_rand()) and uses the best available pseudo-random source. + * bytes normally from mt_rand()) and uses the best available pseudo-random + * source. * * @param $count * The number of characters (bytes) to return in the string. @@ -1916,7 +1953,7 @@ function drupal_random_bytes($count) { } /** - * Calculate a base-64 encoded, URL-safe sha-256 hmac. + * Calculates a base-64 encoded, URL-safe sha-256 hmac. * * @param $data * String to be validated with the hmac. @@ -1934,7 +1971,7 @@ function drupal_hmac_base64($data, $key) { } /** - * Calculate a base-64 encoded, URL-safe sha-256 hash. + * Calculates a base-64 encoded, URL-safe sha-256 hash. * * @param $data * String to be hashed. @@ -1977,7 +2014,8 @@ function drupal_hash_base64($data) { * @see drupal_array_merge_deep_array() */ function drupal_array_merge_deep() { - return drupal_array_merge_deep_array(func_get_args()); + $args = func_get_args(); + return drupal_array_merge_deep_array($args); } /** @@ -2038,20 +2076,22 @@ function drupal_anonymous_user() { } /** - * A string describing a phase of Drupal to load. Each phase adds to the - * previous one, so invoking a later phase automatically runs the earlier - * phases too. The most important usage is that if you want to access the - * Drupal database from a script without loading anything else, you can - * include bootstrap.inc, and call drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE). + * Ensures Drupal is bootstrapped to the specified phase. + * + * The bootstrap phase is an integer constant identifying a phase of Drupal + * to load. Each phase adds to the previous one, so invoking a later phase + * automatically runs the earlier phases as well. To access the Drupal + * database from a script without loading anything else, include bootstrap.inc + * and call drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE). * * @param $phase * A constant. Allowed values are the DRUPAL_BOOTSTRAP_* constants. * @param $new_phase * A boolean, set to FALSE if calling drupal_bootstrap from inside a * function called from drupal_bootstrap (recursion). + * * @return * The most recently completed phase. - * */ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) { // Not drupal_static(), because does not depend on any run-time information. @@ -2130,7 +2170,7 @@ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) { } /** - * Return the time zone of the current user. + * Returns the time zone of the current user. */ function drupal_get_user_timezone() { global $user; @@ -2145,7 +2185,7 @@ function drupal_get_user_timezone() { } /** - * Custom PHP error handler. + * Provides custom PHP error handling. * * @param $error_level * The level of the error raised. @@ -2156,7 +2196,8 @@ function drupal_get_user_timezone() { * @param $line * The line number the error was raised at. * @param $context - * An array that points to the active symbol table at the point the error occurred. + * An array that points to the active symbol table at the point the error + * occurred. */ function _drupal_error_handler($error_level, $message, $filename, $line, $context) { require_once DRUPAL_ROOT . '/includes/errors.inc'; @@ -2164,7 +2205,7 @@ function _drupal_error_handler($error_level, $message, $filename, $line, $contex } /** - * Custom PHP exception handler. + * Provides custom PHP exception handling. * * Uncaught exceptions are those not enclosed in a try/catch block. They are * always fatal: the execution of the script will stop as soon as the exception @@ -2192,7 +2233,7 @@ function _drupal_exception_handler($exception) { } /** - * Bootstrap configuration: Setup script environment and load settings.php. + * Sets up the script environment and loads settings.php. */ function _drupal_bootstrap_configuration() { // Set the Drupal custom error handler. @@ -2207,7 +2248,7 @@ function _drupal_bootstrap_configuration() { } /** - * Bootstrap page cache: Try to serve a page from cache. + * Attempts to serve a page from the cache. */ function _drupal_bootstrap_page_cache() { global $user; @@ -2263,7 +2304,7 @@ function _drupal_bootstrap_page_cache() { } /** - * Bootstrap database: Initialize database system and register autoload functions. + * Initializes the database system and registers autoload functions. */ function _drupal_bootstrap_database() { // Redirect the user to the installation script if Drupal has not been @@ -2315,7 +2356,7 @@ function _drupal_bootstrap_database() { } /** - * Bootstrap variables: Load system variables and all enabled bootstrap modules. + * Loads system variables and all enabled bootstrap modules. */ function _drupal_bootstrap_variables() { global $conf; @@ -2332,7 +2373,7 @@ function _drupal_bootstrap_variables() { } /** - * Bootstrap page header: Invoke hook_boot(), initialize locking system, and send default HTTP headers. + * Invokes hook_boot(), initializes locking system, and sends HTTP headers. */ function _drupal_bootstrap_page_header() { bootstrap_invoke_all('boot'); @@ -2355,8 +2396,7 @@ function drupal_get_bootstrap_phase() { } /** - * Checks the current User-Agent string to see if this is an internal request - * from SimpleTest. If so, returns the test prefix for this test. + * Returns the test prefix if this is an internal request from SimpleTest. * * @return * Either the simpletest prefix (the string "simpletest" followed by any @@ -2392,7 +2432,7 @@ function drupal_valid_test_ua() { } /** - * Generate a user agent string with a HMAC and timestamp for simpletest. + * Generates a user agent string with a HMAC and timestamp for simpletest. */ function drupal_generate_test_ua($prefix) { global $drupal_hash_salt; @@ -2452,7 +2492,7 @@ function drupal_fast_404() { } /** - * Return TRUE if a Drupal installation is currently being attempted. + * Returns TRUE if a Drupal installation is currently being attempted. */ function drupal_installation_attempted() { return defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install'; @@ -2495,10 +2535,9 @@ function get_t() { } /** - * Initialize all the defined language types. + * Initializes all the defined language types. */ function drupal_language_initialize() { - global $language; $types = language_types(); // Ensure the language is correctly returned, even without multilanguage @@ -2518,13 +2557,10 @@ function drupal_language_initialize() { // environments. bootstrap_invoke_all('language_init'); } - - // Send appropriate HTTP-Header for browsers and search engines. - header('Content-Language: ' . $language->language); } /** - * The built-in language types. + * Returns a list of the built-in language types. * * @return * An array of key-values pairs where the key is the language type and the @@ -2539,7 +2575,7 @@ function drupal_language_types() { } /** - * Return true if there is more than one language enabled. + * Returns TRUE if there is more than one language enabled. */ function drupal_multilingual() { // The "language_count" variable stores the number of enabled languages to @@ -2549,7 +2585,7 @@ function drupal_multilingual() { } /** - * Return an array of the available language types. + * Returns an array of the available language types. */ function language_types() { return array_keys(variable_get('language_types', drupal_language_types())); @@ -2606,7 +2642,7 @@ function language_list($field = 'language') { } /** - * Default language used on the site + * Returns the default language used on the site * * @param $property * Optional property of the language object to return @@ -2676,16 +2712,16 @@ function request_path() { } /** - * Return a component of the current Drupal path. + * Returns a component of the current Drupal path. * * When viewing a page at the path "admin/structure/types", for example, arg(0) * returns "admin", arg(1) returns "structure", and arg(2) returns "types". * - * Avoid use of this function where possible, as resulting code is hard to read. - * In menu callback functions, attempt to use named arguments. See the explanation - * in menu.inc for how to construct callbacks that take arguments. When attempting - * to use this function to load an element from the current path, e.g. loading the - * node on a node page, please use menu_get_object() instead. + * Avoid use of this function where possible, as resulting code is hard to + * read. In menu callback functions, attempt to use named arguments. See the + * explanation in menu.inc for how to construct callbacks that take arguments. + * When attempting to use this function to load an element from the current + * path, e.g. loading the node on a node page, use menu_get_object() instead. * * @param $index * The index of the component, where each component is separated by a '/' @@ -2725,6 +2761,8 @@ function arg($index = NULL, $path = NULL) { } /** + * Returns the IP address of the client machine. + * * If Drupal is behind a reverse proxy, we use the X-Forwarded-For header * instead of $_SERVER['REMOTE_ADDR'], which would be the IP address of * the proxy server, and not the client's. The actual header name can be @@ -2774,7 +2812,7 @@ function ip_address() { */ /** - * Get the schema definition of a table, or the whole database schema. + * Gets the schema definition of a table, or the whole database schema. * * The returned schema will include any modifications made by any * module that implements hook_schema_alter(). @@ -2810,11 +2848,17 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) { */ class SchemaCache extends DrupalCacheArray { + /** + * Constructs a SchemaCache object. + */ public function __construct() { // Cache by request method. parent::__construct('schema:runtime:' . ($_SERVER['REQUEST_METHOD'] == 'GET'), 'cache'); } + /** + * Overrides DrupalCacheArray::resolveCacheMiss(). + */ protected function resolveCacheMiss($offset) { $complete_schema = drupal_get_complete_schema(); $value = isset($complete_schema[$offset]) ? $complete_schema[$offset] : NULL; @@ -2825,7 +2869,7 @@ class SchemaCache extends DrupalCacheArray { } /** - * Get the whole database schema. + * Gets the whole database schema. * * The returned schema will include any modifications made by any * module that implements hook_schema_alter(). @@ -2895,13 +2939,14 @@ function drupal_get_complete_schema($rebuild = FALSE) { */ /** - * Confirm that an interface is available. + * Confirms that an interface is available. * * This function is rarely called directly. Instead, it is registered as an * spl_autoload() handler, and PHP calls it for us when necessary. * * @param $interface * The name of the interface to check or load. + * * @return * TRUE if the interface is currently available, FALSE otherwise. */ @@ -2910,13 +2955,14 @@ function drupal_autoload_interface($interface) { } /** - * Confirm that a class is available. + * Confirms that a class is available. * * This function is rarely called directly. Instead, it is registered as an * spl_autoload() handler, and PHP calls it for us when necessary. * * @param $class * The name of the class to check or load. + * * @return * TRUE if the class is currently available, FALSE otherwise. */ @@ -2925,7 +2971,7 @@ function drupal_autoload_class($class) { } /** - * Helper to check for a resource in the registry. + * Checks for a resource in the registry. * * @param $type * The type of resource we are looking up, or one of the constants @@ -2934,6 +2980,7 @@ function drupal_autoload_class($class) { * @param $name * The name of the resource, or NULL if either of the REGISTRY_* constants * is passed in. + * * @return * TRUE if the resource was found, FALSE if not. * NULL if either of the REGISTRY_* constants is passed in as $type. @@ -3005,7 +3052,7 @@ function _registry_check_code($type, $name = NULL) { } /** - * Rescan all enabled modules and rebuild the registry. + * Rescans all enabled modules and rebuilds the registry. * * Rescans all code in modules or includes directories, storing the location of * each interface or class in the database. @@ -3016,7 +3063,7 @@ function registry_rebuild() { } /** - * Update the registry based on the latest files listed in the database. + * Updates the registry based on the latest files listed in the database. * * This function should be used when system_rebuild_module_data() does not need * to be called, because it is already known that the list of files in the @@ -3034,7 +3081,7 @@ function registry_update() { */ /** - * Central static variable storage. + * Provides central static variable storage. * * All functions requiring a static variable to persist or cache data within * a single page request are encouraged to use this function unless it is @@ -3185,7 +3232,7 @@ function &drupal_static($name, $default_value = NULL, $reset = FALSE) { } /** - * Reset one or all centrally stored static variable(s). + * Resets one or all centrally stored static variable(s). * * @param $name * Name of the static variable to reset. Omit to reset all variables. @@ -3195,7 +3242,7 @@ function drupal_static_reset($name = NULL) { } /** - * Detect whether the current script is running in a command-line environment. + * Detects whether the current script is running in a command-line environment. */ function drupal_is_cli() { return (!isset($_SERVER['SERVER_SOFTWARE']) && (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0))); @@ -3203,7 +3250,8 @@ function drupal_is_cli() { /** * Formats text for emphasized display in a placeholder inside a sentence. - * Used automatically by t(). + * + * Used automatically by format_string(). * * @param $text * The text to format (plain-text). @@ -3216,7 +3264,7 @@ function drupal_placeholder($text) { } /** - * Register a function for execution on shutdown. + * Registers a function for execution on shutdown. * * Wrapper for register_shutdown_function() that catches thrown exceptions to * avoid "Exception thrown without a stack frame in Unknown". @@ -3251,7 +3299,7 @@ function &drupal_register_shutdown_function($callback = NULL) { } /** - * Internal function used to execute registered shutdown functions. + * Executes registered shutdown functions. */ function _drupal_shutdown_function() { $callbacks = &drupal_register_shutdown_function(); |