oliverdavies.uk/content/node.c18eb41a-8a26-4a5a-bf17-e1417cebb0dc.yml

81 lines
3 KiB
YAML

uuid:
- value: c18eb41a-8a26-4a5a-bf17-e1417cebb0dc
langcode:
- value: en
type:
- target_id: daily_email
target_type: node_type
target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7
revision_timestamp:
- value: '2025-05-11T09:00:30+00: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: |
Automated tests prevent regressions when upgrading
created:
- value: '2023-10-25T00:00:00+00:00'
changed:
- value: '2025-05-11T09:00:30+00:00'
promote:
- value: false
sticky:
- value: false
default_langcode:
- value: true
revision_translation_affected:
- value: true
path:
- alias: /daily/2023/10/25/automated-tests-prevent-regressions-when-upgrading
langcode: en
body:
- value: |
<p>With Drupal 9 almost being end-of-life and unsupported, I've recently been doing a lot of Drupal 9 to 10 upgrade work.</p>
<p>As it's a major version update, there are breaking changes that mean you may need to change your code.</p>
<p>Here's an example of an error caused by a breaking change:</p>
<blockquote>
<p>Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck().</p>
</blockquote>
<p>To fix this, you need to call the <code>accessCheck()</code> method before executing a query and specify whether it should be checked.</p>
<p>But how do you know if it should be checked?</p>
<p>If you have automated tests that pass beforehand and still pass afterwards, you picked the correct option.</p>
<p>If the test passes before and fails afterwards, you found the bug and can fix it immediately to ensure the functionality works as before.</p>
format: full_html
processed: |
<p>With Drupal 9 almost being end-of-life and unsupported, I've recently been doing a lot of Drupal 9 to 10 upgrade work.</p>
<p>As it's a major version update, there are breaking changes that mean you may need to change your code.</p>
<p>Here's an example of an error caused by a breaking change:</p>
<blockquote>
<p>Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck().</p>
</blockquote>
<p>To fix this, you need to call the <code>accessCheck()</code> method before executing a query and specify whether it should be checked.</p>
<p>But how do you know if it should be checked?</p>
<p>If you have automated tests that pass beforehand and still pass afterwards, you picked the correct option.</p>
<p>If the test passes before and fails afterwards, you found the bug and can fix it immediately to ensure the functionality works as before.</p>
summary: null
field_daily_email_cta: { }