updated core to 7.73

This commit is contained in:
2020-09-24 17:04:08 +02:00
parent 084d28842a
commit 7d87153100
524 changed files with 25194 additions and 7745 deletions
+61 -16
View File
@@ -64,7 +64,7 @@ function image_help($path, $arg) {
$effect = image_effect_definition_load($arg[7]);
return isset($effect['help']) ? ('<p>' . $effect['help'] . '</p>') : NULL;
case 'admin/config/media/image-styles/edit/%/effects/%':
$effect = ($arg[5] == 'add') ? image_effect_definition_load($arg[6]) : image_effect_load($arg[6], $arg[4]);
$effect = ($arg[5] == 'add') ? image_effect_definition_load($arg[6]) : image_effect_load($arg[7], $arg[5]);
return isset($effect['help']) ? ('<p>' . $effect['help'] . '</p>') : NULL;
}
}
@@ -347,6 +347,7 @@ function image_image_default_styles() {
$styles = array();
$styles['thumbnail'] = array(
'label' => 'Thumbnail (100x100)',
'effects' => array(
array(
'name' => 'image_scale',
@@ -357,6 +358,7 @@ function image_image_default_styles() {
);
$styles['medium'] = array(
'label' => 'Medium (220x220)',
'effects' => array(
array(
'name' => 'image_scale',
@@ -367,6 +369,7 @@ function image_image_default_styles() {
);
$styles['large'] = array(
'label' => 'Large (480x480)',
'effects' => array(
array(
'name' => 'image_scale',
@@ -575,6 +578,7 @@ function image_styles() {
$module_styles = module_invoke($module, 'image_default_styles');
foreach ($module_styles as $style_name => $style) {
$style['name'] = $style_name;
$style['label'] = empty($style['label']) ? $style_name : $style['label'];
$style['module'] = $module;
$style['storage'] = IMAGE_STORAGE_DEFAULT;
foreach ($style['effects'] as $key => $effect) {
@@ -689,6 +693,10 @@ function image_style_save($style) {
}
}
else {
// Add a default label when not given.
if (empty($style['label'])) {
$style['label'] = $style['name'];
}
drupal_write_record('image_styles', $style);
$style['is_new'] = TRUE;
}
@@ -758,20 +766,28 @@ function image_style_effects($style) {
*
* @param $include_empty
* If TRUE a <none> option will be inserted in the options array.
* @param $output
* Optional flag determining how the options will be sanitized on output.
* Leave this at the default (CHECK_PLAIN) if you are using the output of
* this function directly in an HTML context, such as for checkbox or radio
* button labels, and do not plan to sanitize it on your own. If using the
* output of this function as select list options (its primary use case), you
* should instead set this flag to PASS_THROUGH to avoid double-escaping of
* the output (the form API sanitizes select list options by default).
*
* @return
* Array of image styles both key and value are set to style name.
* Array of image styles with the machine name as key and the label as value.
*/
function image_style_options($include_empty = TRUE) {
function image_style_options($include_empty = TRUE, $output = CHECK_PLAIN) {
$styles = image_styles();
$options = array();
if ($include_empty && !empty($styles)) {
$options[''] = t('<none>');
}
// Use the array concatenation operator '+' here instead of array_merge(),
// because the latter loses the datatype of the array keys, turning
// associative string keys into numeric ones without warning.
$options = $options + drupal_map_assoc(array_keys($styles));
foreach ($styles as $name => $style) {
$options[$name] = ($output == PASS_THROUGH) ? $style['label'] : check_plain($style['label']);
}
if (empty($options)) {
$options[''] = t('No defined styles');
}
@@ -785,6 +801,8 @@ function image_style_options($include_empty = TRUE) {
*
* @param $style
* The image style
* @param $scheme
* The file scheme, for example 'public' for public files.
*/
function image_style_deliver($style, $scheme) {
$args = func_get_args();
@@ -817,9 +835,9 @@ function image_style_deliver($style, $scheme) {
file_download($scheme, file_uri_target($derivative_uri));
}
else {
$headers = module_invoke_all('file_download', $image_uri);
if (in_array(-1, $headers) || empty($headers)) {
return drupal_access_denied();
$headers = file_download_headers($image_uri);
if (empty($headers)) {
return MENU_ACCESS_DENIED;
}
if (count($headers)) {
foreach ($headers as $name => $value) {
@@ -829,6 +847,12 @@ function image_style_deliver($style, $scheme) {
}
}
// Confirm that the original source image exists before trying to process it.
if (!is_file($image_uri)) {
watchdog('image', 'Source image at %source_image_path not found while trying to generate derivative image at %derivative_path.', array('%source_image_path' => $image_uri, '%derivative_path' => $derivative_uri));
return MENU_NOT_FOUND;
}
// Don't start generating the image if the derivative already exists or if
// generation is in progress in another thread.
$lock_name = 'image_style_deliver:' . $style['name'] . ':' . drupal_hash_base64($image_uri);
@@ -838,6 +862,7 @@ function image_style_deliver($style, $scheme) {
// Tell client to retry again in 3 seconds. Currently no browsers are known
// to support Retry-After.
drupal_add_http_header('Status', '503 Service Unavailable');
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
drupal_add_http_header('Retry-After', 3);
print t('Image generation in progress. Try again shortly.');
drupal_exit();
@@ -859,6 +884,7 @@ function image_style_deliver($style, $scheme) {
else {
watchdog('image', 'Unable to generate the derived image located at %path.', array('%path' => $derivative_uri));
drupal_add_http_header('Status', '500 Internal Server Error');
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
print t('Error generating image.');
drupal_exit();
}
@@ -953,9 +979,12 @@ function image_style_transform_dimensions($style_name, array &$dimensions) {
* An image style array.
*/
function image_style_flush($style) {
$style_directory = drupal_realpath(file_default_scheme() . '://styles/' . $style['name']);
if (is_dir($style_directory)) {
file_unmanaged_delete_recursive($style_directory);
// Delete the style directory in each registered wrapper.
$wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE);
foreach ($wrappers as $wrapper => $wrapper_data) {
if (file_exists($directory = $wrapper . '://styles/' . $style['name'])) {
file_unmanaged_delete_recursive($directory);
}
}
// Let other modules update as necessary on flush.
@@ -993,10 +1022,22 @@ function image_style_flush($style) {
*/
function image_style_url($style_name, $path) {
$uri = image_style_path($style_name, $path);
// The passed-in $path variable can be either a relative path or a full URI.
$original_uri = file_uri_scheme($path) ? file_stream_wrapper_uri_normalize($path) : file_build_uri($path);
// The token query is added even if the 'image_allow_insecure_derivatives'
// variable is TRUE, so that the emitted links remain valid if it is changed
// back to the default FALSE.
$token_query = array(IMAGE_DERIVATIVE_TOKEN => image_style_path_token($style_name, file_stream_wrapper_uri_normalize($path)));
// However, sites which need to prevent the token query from being emitted at
// all can additionally set the 'image_suppress_itok_output' variable to TRUE
// to achieve that (if both are set, the security token will neither be
// emitted in the image derivative URL nor checked for in
// image_style_deliver()).
$token_query = array();
if (!variable_get('image_suppress_itok_output', FALSE)) {
$token_query = array(IMAGE_DERIVATIVE_TOKEN => image_style_path_token($style_name, $original_uri));
}
// If not using clean URLs, the image derivative callback is only available
// with the query string. If the file does not exist, use url() to ensure
@@ -1008,8 +1049,12 @@ function image_style_url($style_name, $path) {
}
$file_url = file_create_url($uri);
// Append the query string with the token.
return $file_url . (strpos($file_url, '?') !== FALSE ? '&' : '?') . drupal_http_build_query($token_query);
// Append the query string with the token, if necessary.
if ($token_query) {
$file_url .= (strpos($file_url, '?') !== FALSE ? '&' : '?') . drupal_http_build_query($token_query);
}
return $file_url;
}
/**