oliverdavies.uk/content/node.6118c41e-e92e-4865-9f1c-64dd19e2bc40.json

91 lines
4.3 KiB
JSON
Raw Normal View History

2025-04-16 23:34:31 +01:00
{
"uuid": [
{
2025-05-11 09:40:11 +01:00
"value": "6118c41e-e92e-4865-9f1c-64dd19e2bc40"
2025-04-16 23:34:31 +01:00
}
],
"langcode": [
{
"value": "en"
}
],
"type": [
{
"target_id": "daily_email",
"target_type": "node_type",
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
}
],
"revision_timestamp": [
{
2025-05-11 09:40:11 +01:00
"value": "2025-05-11T09:00:40+00:00"
2025-04-16 23:34:31 +01:00
}
],
"revision_uid": [
{
"target_type": "user",
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
}
],
"revision_log": [],
"status": [
{
"value": true
}
],
"uid": [
{
"target_type": "user",
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
}
],
"title": [
{
"value": "What is deprecated code?\n"
}
],
"created": [
{
"value": "2023-05-17T00:00:00+00:00"
}
],
"changed": [
{
2025-05-11 09:40:11 +01:00
"value": "2025-05-11T09:00:40+00:00"
2025-04-16 23:34:31 +01:00
}
],
"promote": [
{
"value": false
}
],
"sticky": [
{
"value": false
}
],
"default_langcode": [
{
"value": true
}
],
"revision_translation_affected": [
{
"value": true
}
],
"path": [
{
"alias": "\/daily\/2023\/05\/17\/what-is-deprecated-code",
2025-04-29 14:30:51 +01:00
"langcode": "en"
2025-04-16 23:34:31 +01:00
}
],
"body": [
{
"value": "\n <p>Deprecating code is a way of identifying code that will be removed in a future major version.<\/p>\n\n<p>For example, the <code>drupal_set_message()<\/code> function was deprecated in Drupal 8.5 and removed in Drupal 9 as the <code>messenger<\/code> service replaced it.<\/p>\n\n<p>Once it was deprecated, the function was changed to use the new service to avoid duplicating code and a message was added to notify Developers:<\/p>\n\n<pre><code class=\"language-php\">function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) {\n @trigger_error('drupal_set_message() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\Core\\Messenger\\MessengerInterface::addMessage() instead. See https:\/\/www.drupal.org\/node\/2774931', E_USER_DEPRECATED);\n\n $messenger = \\Drupal::messenger();\n if (isset($message)) {\n $messenger-&gt;addMessage($message, $type, $repeat);\n }\n\n return $messenger-&gt;all();\n}\n<\/code><\/pre>\n\n<p>This approach means that code can be refactored without breaking backwards-compatibility and, to upgrade any custom code to be compatible with Drupal 9, any references to <code>drupal_set_message()<\/code> just needed to be updated to use the new Messenger service.<\/p>\n\n<p>No large rewrite needed!<\/p>\n\n ",
"format": "full_html",
"processed": "\n <p>Deprecating code is a way of identifying code that will be removed in a future major version.<\/p>\n\n<p>For example, the <code>drupal_set_message()<\/code> function was deprecated in Drupal 8.5 and removed in Drupal 9 as the <code>messenger<\/code> service replaced it.<\/p>\n\n<p>Once it was deprecated, the function was changed to use the new service to avoid duplicating code and a message was added to notify Developers:<\/p>\n\n<pre><code class=\"language-php\">function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) {\n @trigger_error('drupal_set_message() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\Core\\Messenger\\MessengerInterface::addMessage() instead. See https:\/\/www.drupal.org\/node\/2774931', E_USER_DEPRECATED);\n\n $messenger = \\Drupal::messenger();\n if (isset($message)) {\n $messenger-&gt;addMessage($message, $type, $repeat);\n }\n\n return $messenger-&gt;all();\n}\n<\/code><\/pre>\n\n<p>This approach means that code can be refactored without breaking backwards-compatibility and, to upgrade any custom code to be compatible with Drupal 9, any references to <code>drupal_set_message()<\/code> just needed to be updated to use the new Messenger service.<\/p>\n\n<p>No large rewrite needed!<\/p>\n\n ",
"summary": null
}
]
}