Update to Drupal 8.0.0-rc3. For more information, see https://www.drupal.org/node/2608078

This commit is contained in:
Pantheon Automation 2015-11-04 11:11:27 -08:00 committed by Greg Anderson
parent 6419a031d7
commit 4afb23bbd3
762 changed files with 20080 additions and 6368 deletions

View file

@ -200,7 +200,6 @@ function drupal_get_filename($type, $name, $filename = NULL) {
// Profiles are converted into modules in system_rebuild_module_data().
// @todo Remove false-exposure of profiles as modules.
$original_type = $type;
if ($type == 'profile') {
$type = 'module';
}
@ -258,56 +257,39 @@ function drupal_get_path($type, $name) {
/**
* Translates a string to the current language or to a given language.
*
* The t() function serves two purposes. First, at run-time it translates
* user-visible text into the appropriate language. Second, various mechanisms
* that figure out what text needs to be translated work off t() -- the text
* inside t() calls is added to the database of strings to be translated.
* These strings are expected to be in English, so the first argument should
* always be in English. To enable a fully-translatable site, it is important
* that all human-readable text that will be displayed on the site or sent to
* a user is passed through the t() function, or a related function. See the
* @link https://www.drupal.org/node/322729 Localization API @endlink pages for
* more information, including recommendations on how to break up or not
* break up strings for translation.
* In order for strings to be localized, make them available in one of the ways
* supported by the
* @link https://www.drupal.org/node/322729 Localization API @endlink. When
* possible, use the \Drupal\Core\StringTranslation\StringTranslationTrait
* $this->t(). Otherwise create a new
* \Drupal\Core\StringTranslation\TranslatableMarkup object directly.
*
* @section sec_translating_vars Translating Variables
* You should never use t() to translate variables, such as calling t($text)
* unless the text that the variable holds has been passed through t()
* elsewhere (e.g., $text is one of several translated literal strings in an
* array). It is especially important never to call t($user_text) where
* $user_text is some text that a user entered - doing that can lead to
* cross-site scripting and other security problems. However, you can use
* variable substitution in your string, to put variable text such as user
* names or link URLs into translated text. Variable substitution looks like
* this:
* @code
* $text = t("@name's blog", array('@name' => $account->getDisplayName()));
* @endcode
* Basically, you can put variables like @name into your string, and t() will
* substitute their sanitized values at translation time. (See the
* Localization API pages referenced above and the documentation of
* \Drupal\Component\Utility\SafeMarkup::format() for details about how to
* define variables in your string.). Translators can then rearrange the string
* as necessary for the language (e.g., in Spanish, it might be "blog de
* @name").
* See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for
* important security information and usage guidelines.
*
* @param $string
* A string containing the English string to translate.
* @param $args
* 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 \Drupal\Component\Utility\SafeMarkup::format() for details.
* @param $options
* An associative array of additional options, with the following elements:
* - 'langcode' (defaults to the current language): The language code to
* @param string $string
* A string containing the English text to translate.
* @param array $args
* (optional) 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
* \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for
* details.
* @param array $options
* (optional) An associative array of additional options, with the following
* elements:
* - 'langcode' (defaults to the current language): A language code, to
* translate to a language other than what is used to display the page.
* - 'context' (defaults to the empty context): The context the source string
* belongs to.
*
* @return
* The translated string.
* @return \Drupal\Core\StringTranslation\TranslatableMarkup
* An object that, when cast to a string, returns the translated string.
*
* @see \Drupal\Component\Render\FormattableMarkup::placeholderFormat()
* @see \Drupal\Core\StringTranslation\StringTranslationTrait::t()
* @see \Drupal\Core\StringTranslation\TranslatableMarkup::__construct()
*
* @see \Drupal\Component\Utility\SafeMarkup::format()
* @ingroup sanitization
*/
function t($string, array $args = array(), array $options = array()) {
@ -349,7 +331,7 @@ function format_string($string, array $args) {
* @param $text
* The text to check.
*
* @return
* @return bool
* TRUE if the text is valid UTF-8, FALSE if not.
*
* @see \Drupal\Component\Utility\Unicode::validateUtf8()
@ -582,7 +564,7 @@ function _drupal_exception_handler($exception) {
catch (\Throwable $error) {
_drupal_exception_handler_additional($exception, $error);
}
// In order to be compatibile with PHP 5 we also catch regular Exceptions.
// In order to be compatible with PHP 5 we also catch regular Exceptions.
catch (\Exception $exception2) {
_drupal_exception_handler_additional($exception, $exception2);
}
@ -998,7 +980,7 @@ function _drupal_shutdown_function() {
catch (\Throwable $error) {
_drupal_shutdown_function_handle_exception($error);
}
// In order to be compatibile with PHP 5 we also catch regular Exceptions.
// In order to be compatible with PHP 5 we also catch regular Exceptions.
catch (\Exception $exception) {
_drupal_shutdown_function_handle_exception($exception);
}

View file

@ -884,6 +884,10 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) {
* @return string|\Drupal\Component\Render\MarkupInterface
* The rendered HTML of all children of the element.
*
* @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Avoid early
* rendering when possible or loop through the elements and render them as
* they are available.
*
* @see drupal_render()
*/
function drupal_render_children(&$element, $children_keys = NULL) {

View file

@ -156,7 +156,7 @@ function file_default_scheme() {
* The normalized URI.
*/
function file_stream_wrapper_uri_normalize($uri) {
$scheme = file_uri_scheme($uri);
$scheme = \Drupal::service('file_system')->uriScheme($uri);
if (file_stream_wrapper_valid_scheme($scheme)) {
$target = file_uri_target($uri);
@ -199,7 +199,7 @@ function file_create_url($uri) {
// file server.
\Drupal::moduleHandler()->alter('file_url', $uri);
$scheme = file_uri_scheme($uri);
$scheme = \Drupal::service('file_system')->uriScheme($uri);
if (!$scheme) {
// Allow for:
@ -266,7 +266,6 @@ function file_url_transform_relative($file_url) {
// Unfortunately, we pretty much have to duplicate Symfony's
// Request::getHttpHost() method because Request::getPort() may return NULL
// instead of a port number.
$http_host = '';
$request = \Drupal::request();
$host = $request->getHost();
$scheme = $request->getScheme();
@ -300,7 +299,7 @@ function file_url_transform_relative($file_url) {
* otherwise.
*/
function file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS) {
if (!file_stream_wrapper_valid_scheme(file_uri_scheme($directory))) {
if (!file_stream_wrapper_valid_scheme(\Drupal::service('file_system')->uriScheme($directory))) {
// Only trim if we're not dealing with a stream.
$directory = rtrim($directory, '/\\');
}
@ -349,7 +348,7 @@ function file_ensure_htaccess() {
* if one is already present. Defaults to FALSE.
*/
function file_save_htaccess($directory, $private = TRUE, $force_overwrite = FALSE) {
if (file_uri_scheme($directory)) {
if (\Drupal::service('file_system')->uriScheme($directory)) {
$htaccess_path = file_stream_wrapper_uri_normalize($directory . '/.htaccess');
}
else {
@ -407,7 +406,7 @@ function file_htaccess_lines($private = TRUE) {
*/
function file_valid_uri($uri) {
// Assert that the URI has an allowed scheme. Bare paths are not allowed.
$uri_scheme = file_uri_scheme($uri);
$uri_scheme = \Drupal::service('file_system')->uriScheme($uri);
if (!file_stream_wrapper_valid_scheme($uri_scheme)) {
return FALSE;
}

View file

@ -210,7 +210,6 @@ function drupal_get_database_types() {
* @endcode
* gets dumped as:
* @code
* $config_directories['active'] = 'config_hash/active';
* $config_directories['sync'] = 'config_hash/sync'
* @endcode
*/
@ -524,8 +523,7 @@ function drupal_install_config_directories() {
* Ensures that the config directory exists and is writable, or can be made so.
*
* @param string $type
* Type of config directory to return. Drupal core provides 'active' and
* 'sync'.
* Type of config directory to return. Drupal core provides 'sync'.
*
* @return bool
* TRUE if the config directory exists and is writable.

View file

@ -10,18 +10,18 @@ use Drupal\Component\Utility\UrlHelper;
/**
* Returns the current page being requested for display within a pager.
*
* @param $element
* An optional integer to distinguish between multiple pagers on one page.
* @param int $element
* (optional) An integer to distinguish between multiple pagers on one page.
*
* @return
* The number of the current requested page, within the pager represented by
* $element. This is determined from the URL query parameter
* \Drupal::request()->query->get('page'), or 0 by default. Note that this
* number may differ from the actual page being displayed. For example, if a
* search for "example text" brings up three pages of results, but a users
* visits search/node/example+text?page=10, this function will return 10, even
* though the default pager implementation adjusts for this and still displays
* the third page of search results at that URL.
* @return int
* The number of the current requested page, within the pager represented by
* $element. This is determined from the URL query parameter
* \Drupal::request()->query->get('page'), or 0 by default. Note that this
* number may differ from the actual page being displayed. For example, if a
* search for "example text" brings up three pages of results, but a user
* visits search/node/example+text?page=10, this function will return 10,
* even though the default pager implementation adjusts for this and still
* displays the third page of search results at that URL.
*
* @see pager_default_initialize()
*/
@ -35,11 +35,11 @@ function pager_find_page($element = 0) {
}
/**
* Initializes a pager for _theme('pager').
* Initializes a pager.
*
* This function sets up the necessary global variables so that future calls
* to _theme('pager') will render a pager that correctly corresponds to the
* items being displayed.
* This function sets up the necessary global variables so that the render
* system will correctly process #type 'pager' render arrays to output pagers
* that correspond to the items being displayed.
*
* If the items being displayed result from a database query performed using
* Drupal's database API, and if you have control over the construction of the
@ -54,7 +54,7 @@ function pager_find_page($element = 0) {
* However, if you are using a different method for generating the items to be
* paged through, then you should call this function in preparation.
*
* The following example shows how this function can be used in a page callback
* The following example shows how this function can be used in a controller
* that invokes an external datastore with an SQL-like syntax:
* @code
* // First find the total number of items and initialize the pager.
@ -63,21 +63,22 @@ function pager_find_page($element = 0) {
* $num_per_page = \Drupal::config('mymodule.settings')->get('num_per_page');
* $page = pager_default_initialize($total, $num_per_page);
*
* // Next, retrieve and display the items for the current page.
* // Next, retrieve the items for the current page and put them into a
* // render array.
* $offset = $num_per_page * $page;
* $result = mymodule_select("SELECT * FROM data " . $where . " LIMIT %d, %d", $offset, $num_per_page)->fetchAll();
* $output = drupal_render(
* $render = [];
* $render[] = [
* '#theme' => 'mymodule_results',
* '#result' => $result,
* );
* ];
*
* // Finally, display the pager controls, and return.
* $pager = array('#type' => 'pager');
* $output .= drupal_render($pager);
* return $output;
* // Finally, add the pager to the render array, and return.
* $render[] = ['#type' => 'pager'];
* return $render;
* @endcode
*
* A second example involves a page callback that invokes an external search
* A second example involves a controller that invokes an external search
* service where the total number of matching results is provided as part of
* the returned set (so that we do not need a separate query in order to obtain
* this information). Here, we call pager_find_page() to calculate the desired
@ -95,28 +96,27 @@ function pager_find_page($element = 0) {
* // Now that we have the total number of results, initialize the pager.
* pager_default_initialize($result->total, $num_per_page);
*
* // Display the search results.
* $search_results = array(
* // Create a render array with the search results.
* $render = [];
* $render[] = [
* '#theme' => 'search_results',
* '#results' => $result->data,
* '#type' => 'remote',
* );
* $output = drupal_render($search_results);
* ];
*
* // Finally, display the pager controls, and return.
* $pager = array('#type' => 'pager');
* $output .= drupal_render($pager);
* return $output;
* // Finally, add the pager to the render array, and return.
* $render[] = ['#type' => 'pager'];
* return $render;
* @endcode
*
* @param $total
* The total number of items to be paged.
* @param $limit
* The number of items the calling code will display per page.
* @param $element
* An optional integer to distinguish between multiple pagers on one page.
* @param int $total
* The total number of items to be paged.
* @param int $limit
* The number of items the calling code will display per page.
* @param int $element
* (optional) An integer to distinguish between multiple pagers on one page.
*
* @return
* @return int
* The number of the current page, within the pager represented by $element.
* This is determined from the URL query parameter
* \Drupal::request()->query->get('page), or 0 by default. However, if a page
@ -140,7 +140,7 @@ function pager_default_initialize($total, $limit, $element = 0) {
/**
* Compose a URL query parameter array for pager links.
*
* @return
* @return array
* A URL query parameter array that consists of all components of the current
* page request except for those pertaining to paging.
*/
@ -284,18 +284,23 @@ function template_preprocess_pager(&$variables) {
}
/**
* Get the query parameter array of a pager link.
* Gets the URL query parameter array of a pager link.
*
* Adds or adjusts the 'page' parameter to make sure that, following the link,
* the requested $page for the given $element is displayed.
* The 'page' parameter is a comma-delimited string, where each value is the
* target page for the corresponding pager $element.
* Adds to or adjusts the 'page' URL query parameter so that if you follow the
* link, you'll get page $index for pager $element on the page.
*
* The 'page' URL query parameter is a comma-delimited string, where each value
* is the target content page for the corresponding pager $element. For
* instance, if we have 5 pagers on a single page, and we want to have a link
* to a page that should display the 6th content page for the 3rd pager, and
* the 1st content page for all the other pagers, then the URL query will look
* like this: ?page=0,0,5,0,0 (page numbering starts at zero).
*
* @param array $query
* An associative array of query parameters to add to.
* @param integer $element
* An associative array of URL query parameters to add to.
* @param int $element
* An integer to distinguish between multiple pagers on one page.
* @param integer $index
* @param int $index
* The index of the target page, for the given element, in the pager array.
*
* @return array

View file

@ -863,9 +863,6 @@ function template_preprocess_image(&$variables) {
* rows.
*/
function template_preprocess_table(&$variables) {
$is_sticky = !empty($variables['sticky']);
$is_responsive = !empty($variables['responsive']);
// Format the table columns:
if (!empty($variables['colgroups'])) {
foreach ($variables['colgroups'] as &$colgroup) {