Mercurial > hg > isophonics-drupal-site
comparison core/includes/common.inc @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 129ea1e6d783 |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
6 * | 6 * |
7 * The functions that are critical and need to be available even when serving | 7 * The functions that are critical and need to be available even when serving |
8 * a cached page are instead located in bootstrap.inc. | 8 * a cached page are instead located in bootstrap.inc. |
9 */ | 9 */ |
10 | 10 |
11 use Drupal\Component\Gettext\PoItem; | |
11 use Drupal\Component\Serialization\Json; | 12 use Drupal\Component\Serialization\Json; |
12 use Drupal\Component\Utility\Bytes; | 13 use Drupal\Component\Utility\Bytes; |
14 use Drupal\Component\Utility\Environment; | |
13 use Drupal\Component\Utility\Html; | 15 use Drupal\Component\Utility\Html; |
14 use Drupal\Component\Utility\SortArray; | 16 use Drupal\Component\Utility\SortArray; |
15 use Drupal\Component\Utility\UrlHelper; | 17 use Drupal\Component\Utility\UrlHelper; |
16 use Drupal\Core\Cache\Cache; | 18 use Drupal\Core\Cache\Cache; |
19 use Drupal\Core\Render\BubbleableMetadata; | |
20 use Drupal\Core\Render\Element; | |
17 use Drupal\Core\Render\Element\Link; | 21 use Drupal\Core\Render\Element\Link; |
22 use Drupal\Core\Render\HtmlResponseAttachmentsProcessor; | |
18 use Drupal\Core\Render\Markup; | 23 use Drupal\Core\Render\Markup; |
19 use Drupal\Core\StringTranslation\TranslatableMarkup; | 24 use Drupal\Core\StringTranslation\TranslatableMarkup; |
20 use Drupal\Core\StringTranslation\PluralTranslatableMarkup; | |
21 use Drupal\Core\Render\BubbleableMetadata; | |
22 use Drupal\Core\Render\Element; | |
23 | 25 |
24 /** | 26 /** |
25 * @defgroup php_wrappers PHP wrapper functions | 27 * @defgroup php_wrappers PHP wrapper functions |
26 * @{ | 28 * @{ |
27 * Functions that are wrappers or custom implementations of PHP functions. | 29 * Functions that are wrappers or custom implementations of PHP functions. |
124 | 126 |
125 /** | 127 /** |
126 * The delimiter used to split plural strings. | 128 * The delimiter used to split plural strings. |
127 * | 129 * |
128 * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. | 130 * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. |
129 * Use \Drupal\Core\StringTranslation\PluralTranslatableMarkup::DELIMITER | 131 * Use Drupal\Component\Gettext\PoItem::DELIMITER instead. |
130 * instead. | 132 */ |
131 */ | 133 const LOCALE_PLURAL_DELIMITER = PoItem::DELIMITER; |
132 const LOCALE_PLURAL_DELIMITER = PluralTranslatableMarkup::DELIMITER; | |
133 | 134 |
134 /** | 135 /** |
135 * Prepares a 'destination' URL query parameter. | 136 * Prepares a 'destination' URL query parameter. |
136 * | 137 * |
137 * Used to direct the user back to the referring page after completing a form. | 138 * Used to direct the user back to the referring page after completing a form. |
209 * because Drupal\Core\Template\Attribute expects those values to be | 210 * because Drupal\Core\Template\Attribute expects those values to be |
210 * plain-text strings. To pass a filtered URI to | 211 * plain-text strings. To pass a filtered URI to |
211 * Drupal\Core\Template\Attribute, call | 212 * Drupal\Core\Template\Attribute, call |
212 * \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() instead. | 213 * \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() instead. |
213 * | 214 * |
214 * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. | 215 * @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. |
215 * Use UrlHelper::stripDangerousProtocols() or UrlHelper::filterBadProtocol() | 216 * Use UrlHelper::stripDangerousProtocols() or UrlHelper::filterBadProtocol() |
216 * instead. UrlHelper::stripDangerousProtocols() can be used in conjunction | 217 * instead. UrlHelper::stripDangerousProtocols() can be used in conjunction |
217 * with \Drupal\Component\Render\FormattableMarkup and an @variable | 218 * with \Drupal\Component\Render\FormattableMarkup and an @variable |
218 * placeholder which will perform the necessary escaping. | 219 * placeholder which will perform the necessary escaping. |
219 * UrlHelper::filterBadProtocol() is functionality equivalent to check_url() | 220 * UrlHelper::filterBadProtocol() is functionality equivalent to check_url() |
223 * @see \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() | 224 * @see \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() |
224 * @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol() | 225 * @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol() |
225 * @see https://www.drupal.org/node/2560027 | 226 * @see https://www.drupal.org/node/2560027 |
226 */ | 227 */ |
227 function check_url($uri) { | 228 function check_url($uri) { |
229 @trigger_error(__FUNCTION__ . '() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use UrlHelper::stripDangerousProtocols() or UrlHelper::filterBadProtocol() instead. See https://www.drupal.org/node/2560027', E_USER_DEPRECATED); | |
228 return Html::escape(UrlHelper::stripDangerousProtocols($uri)); | 230 return Html::escape(UrlHelper::stripDangerousProtocols($uri)); |
229 } | 231 } |
230 | 232 |
231 /** | 233 /** |
232 * @} End of "defgroup sanitization". | 234 * @} End of "defgroup sanitization". |
327 * | 329 * |
328 * @see \Drupal\Core\Datetime\DateFormatter::format() | 330 * @see \Drupal\Core\Datetime\DateFormatter::format() |
329 * @see https://www.drupal.org/node/1876852 | 331 * @see https://www.drupal.org/node/1876852 |
330 */ | 332 */ |
331 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) { | 333 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) { |
334 @trigger_error("format_date() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::service('date.formatter')->format() instead. See https://www.drupal.org/node/1876852", E_USER_DEPRECATED); | |
332 return \Drupal::service('date.formatter')->format($timestamp, $type, $format, $timezone, $langcode); | 335 return \Drupal::service('date.formatter')->format($timestamp, $type, $format, $timezone, $langcode); |
333 } | 336 } |
334 | 337 |
335 /** | 338 /** |
336 * Returns an ISO8601 formatted date based on the given date. | 339 * Returns an ISO8601 formatted date based on the given date. |
337 * | 340 * |
338 * @param $date | 341 * @param string $date |
339 * A UNIX timestamp. | 342 * A UNIX timestamp. |
340 * | 343 * |
341 * @return string | 344 * @return string |
342 * An ISO8601 formatted date. | 345 * An ISO8601 formatted date. |
346 * | |
347 * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use | |
348 * date('c', $date) instead. | |
349 * | |
350 * @see https://www.drupal.org/node/2999991 | |
343 */ | 351 */ |
344 function date_iso8601($date) { | 352 function date_iso8601($date) { |
353 @trigger_error('date_iso8601() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use date("c", $date) instead. See https://www.drupal.org/node/2999991.', E_USER_DEPRECATED); | |
345 // The DATE_ISO8601 constant cannot be used here because it does not match | 354 // The DATE_ISO8601 constant cannot be used here because it does not match |
346 // date('c') and produces invalid RDF markup. | 355 // date('c') and produces invalid RDF markup. |
347 return date('c', $date); | 356 return date('c', $date); |
348 } | 357 } |
349 | 358 |
352 */ | 361 */ |
353 | 362 |
354 /** | 363 /** |
355 * Formats an attribute string for an HTTP header. | 364 * Formats an attribute string for an HTTP header. |
356 * | 365 * |
357 * @param $attributes | 366 * @param array $attributes |
358 * An associative array of attributes such as 'rel'. | 367 * An associative array of attributes such as 'rel'. |
359 * | 368 * |
360 * @return | 369 * @return string |
361 * A ; separated string ready for insertion in a HTTP header. No escaping is | 370 * A ; separated string ready for insertion in a HTTP header. No escaping is |
362 * performed for HTML entities, so this string is not safe to be printed. | 371 * performed for HTML entities, so this string is not safe to be printed. |
372 * | |
373 * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use | |
374 * \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes() | |
375 * instead. | |
376 * | |
377 * @see https://www.drupal.org/node/3000051 | |
363 */ | 378 */ |
364 function drupal_http_header_attributes(array $attributes = []) { | 379 function drupal_http_header_attributes(array $attributes = []) { |
365 foreach ($attributes as $attribute => &$data) { | 380 @trigger_error("drupal_http_header_attributes() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes() instead. See https://www.drupal.org/node/3000051", E_USER_DEPRECATED); |
366 if (is_array($data)) { | 381 return HtmlResponseAttachmentsProcessor::formatHttpHeaderAttributes($attributes); |
367 $data = implode(' ', $data); | |
368 } | |
369 $data = $attribute . '="' . $data . '"'; | |
370 } | |
371 return $attributes ? ' ' . implode('; ', $attributes) : ''; | |
372 } | 382 } |
373 | 383 |
374 /** | 384 /** |
375 * Attempts to set the PHP maximum execution time. | 385 * Attempts to set the PHP maximum execution time. |
376 * | 386 * |
396 * @param $time_limit | 406 * @param $time_limit |
397 * An integer specifying the new time limit, in seconds. A value of 0 | 407 * An integer specifying the new time limit, in seconds. A value of 0 |
398 * indicates unlimited execution time. | 408 * indicates unlimited execution time. |
399 * | 409 * |
400 * @ingroup php_wrappers | 410 * @ingroup php_wrappers |
411 * | |
412 * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use | |
413 * \Drupal\Core\Environment::setTimeLimit() instead. | |
414 * | |
415 * @see https://www.drupal.org/node/3000058 | |
401 */ | 416 */ |
402 function drupal_set_time_limit($time_limit) { | 417 function drupal_set_time_limit($time_limit) { |
403 if (function_exists('set_time_limit')) { | 418 @trigger_error('drupal_set_time_limit() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Environment::setTimeLimit() instead. See https://www.drupal.org/node/3000058.', E_USER_DEPRECATED); |
404 $current = ini_get('max_execution_time'); | 419 Environment::setTimeLimit($time_limit); |
405 // Do not set time limit if it is currently unlimited. | |
406 if ($current != 0) { | |
407 @set_time_limit($time_limit); | |
408 } | |
409 } | |
410 } | 420 } |
411 | 421 |
412 /** | 422 /** |
413 * Returns the base URL path (i.e., directory) of the Drupal installation. | 423 * Returns the base URL path (i.e., directory) of the Drupal installation. |
414 * | 424 * |
1214 * | 1224 * |
1215 * @return | 1225 * @return |
1216 * NULL if compatible, otherwise the original dependency version string that | 1226 * NULL if compatible, otherwise the original dependency version string that |
1217 * caused the incompatibility. | 1227 * caused the incompatibility. |
1218 * | 1228 * |
1219 * @see \Drupal\Core\Extension\ModuleHandler::parseDependency() | 1229 * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use |
1230 * \Drupal\Core\Extension\Dependency::isCompatible() instead. | |
1231 * | |
1232 * @see https://www.drupal.org/node/2756875 | |
1220 */ | 1233 */ |
1221 function drupal_check_incompatibility($v, $current_version) { | 1234 function drupal_check_incompatibility($v, $current_version) { |
1235 @trigger_error(__FUNCTION__ . '() is deprecated. Use \Drupal\Core\Extension\Dependency::isCompatible() instead. See https://www.drupal.org/node/2756875', E_USER_DEPRECATED); | |
1222 if (!empty($v['versions'])) { | 1236 if (!empty($v['versions'])) { |
1223 foreach ($v['versions'] as $required_version) { | 1237 foreach ($v['versions'] as $required_version) { |
1224 if ((isset($required_version['op']) && !version_compare($current_version, $required_version['version'], $required_version['op']))) { | 1238 if ((isset($required_version['op']) && !version_compare($current_version, $required_version['version'], $required_version['op']))) { |
1225 return $v['original_version']; | 1239 return $v['original_version']; |
1226 } | 1240 } |