Skip to content

Commit 34c8e5f

Browse files
committed
[docs] Document the final removal process
1 parent f643474 commit 34c8e5f

File tree

1 file changed

+56
-28
lines changed
  • general/development/policies/deprecation

1 file changed

+56
-28
lines changed

general/development/policies/deprecation/index.md

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@ In an open source project, the end use of the codebase varies. People may have c
1818

1919
## What is Moodle's deprecation policy?
2020

21-
- Deprecations should only be on the `main` branch, not on stables (exceptions may be made for some external service integrations)
21+
- Deprecations should only be on the `main` branch, not on stables. Exceptions to this may be made in certain conditions, including:
22+
- for some external service integrations
23+
- where a feature is discovered to have been broken irreparably
24+
- to address security issues
2225
- Deprecations apply to all public APIs, classes, and files.
23-
- Removal of a function, class, or file may only be considered after a minimum of 4 major releases since the deprecation. Example: anything deprecated in 3.2 means that it will be removed in 3.6
24-
- All deprecations should emit debugging notices where possible
2526
- All deprecations should be noted with an [upgrade note](../../upgradenotes.md).
27+
- Deprecations are split into three stages:
28+
1. Initial deprecation
29+
2. Final deprecation
30+
3. Removal
31+
- All deprecations should emit debugging notices where possible
2632

2733
:::danger What does it mean for an API to be considered "Public"
2834

@@ -41,13 +47,13 @@ Once it is decided that a function should be deprecated, a two-step process shou
4147

4248
:::note
4349

44-
Both steps should always happen as earlier as possible in the 6-months period between major releases, so all developers will have time to adjust their code and ensure it will work in the next release. Obviously, **no changes will be allowed after code freeze** (the APIs must remain 100% unmodified after it).
50+
These steps should always happen as early as possible in the 6-months period between major releases. This ensures that developers will have sufficient time to adjust their code and confirm compatibility with the next release. **After the code freeze, no changes wll be allowed.** - APIs must remain completely unchanged.
4551

4652
:::
4753

48-
### Step 1. Immediate action
54+
### Step 1. Immediate action - Initial deprecation
4955

50-
Deprecation affects only the current main version, in other words, the deprecation only becomes effective after the next [major release](../../../releases.md).
56+
Deprecation affects only the current `main` version, in other words, the deprecation only becomes effective after the next [major release](../../../releases.md).
5157

5258
- If the function is not a member of a class (in other words, it is an independent function), it should be moved, with its PHPDoc and all comments, to `lib/deprecatedlib.php`, which is included everywhere. If the function is a class member, it will need to be deprecated in its current location.
5359
- Deprecated behat step definitions should be moved to `lib/tests/behat/behat_deprecated.php`. Steps that are part of a component should be moved to `$COMPONENT_DIRECTORY/tests/behat/behat_<COMPONENT>_deprecated.php` instead. Deprecated function should call to `behat_deprecated::deprecated_message()` proposing an alternative to the deprecated method.
@@ -58,19 +64,11 @@ Deprecation affects only the current main version, in other words, the deprecati
5864
- Add @deprecated tag on class level PHPDoc block
5965
- Add @deprecated tag on the PHPDoc block of all public methods
6066
- Add debugging on all of the public methods
61-
- Besides, if the entire class is being moved (for example, moving multiple class definitions from a monolithic file in to individual files), follow the process for [renaming classes](/docs/apis/commonfiles#dbrenamedclassesphp).
67+
- If the entire class is being moved (for example, moving multiple class definitions from a monolithic file in to individual files), follow the process for [renaming classes](/docs/apis/commonfiles#dbrenamedclassesphp).
6268
- A debugging message should be added to the function so that, when [developer debugging mode](https://docs.moodle.org/en/Debugging) is on, attention is drawn to the deprecation. The message should state that the function being called has been deprecated. The message should help a developer whose code currently calls the function that has gone. Tell them what they should do instead.
6369

6470
<Tabs>
6571

66-
<TabItem value="debugging" label="Deprecations using debugging">
67-
68-
```php
69-
debugging('foobar() is deprecated. Please use foobar::blah() instead.', DEBUG_DEVELOPER);
70-
```
71-
72-
</TabItem>
73-
7472
<TabItem value="core_deprecation" label="Using the \core\deprecation API from Moodle 4.4">
7573

7674
```php
@@ -84,6 +82,14 @@ public function foobar(int $old, array $params): array {
8482

8583
</TabItem>
8684

85+
<TabItem value="debugging" label="Deprecations using debugging">
86+
87+
```php
88+
debugging('foobar() is deprecated. Please use foobar::blah() instead.', DEBUG_DEVELOPER);
89+
```
90+
91+
</TabItem>
92+
8793
</Tabs>
8894

8995
- Unit tests that call the function should have `assertDebuggingCalled()` added to allow them to continue running.
@@ -124,7 +130,7 @@ The final deprecation policy for Moodle LMS has been updated to align more close
124130
- Functions that have been deprecated in an LTS version (the last version within a series) will be up for final deprecation on the next major version after the next LTS release (`[X+2].0`).
125131

126132
<ValidExample title="Example">
127-
- Functions deprecated in Moodle 4.4 (Series 4) and below will be up for final deprecation in Moodle 5.0 (the first Series 5 Moodle version).
133+
- Functions deprecated in Moodle 4.4 (Series 4) and below will be considered for final deprecation in Moodle 5.0 (the first Series 5 Moodle version).
128134
- Functions deprecated in Moodle 4.5 (LTS) will be up for final deprecation in Moodle 6.0 (the first release for Series 6 right after the Moodle 5.3 (LTS) release).
129135
</ValidExample>
130136

@@ -134,39 +140,61 @@ The final deprecation policy for Moodle LMS has been updated to align more close
134140

135141
<Tabs>
136142

137-
<TabItem value="debugging" label="Deprecations using debugging">
143+
<TabItem value="core_deprecation" label="Using the \core\deprecation API from Moodle 4.4">
138144

139145
```php
140-
throw new coding_exception(
141-
'foobar() can not be used any more, please use foobar::blah'
142-
);
146+
#[\core\attribute\deprecated(
147+
'foobar::blah()',
148+
since: '4.4',
149+
mdl: 'MDL-XXXXX',
150+
final: true,
151+
)]
152+
public function foobar(int $old, array $params): array {
153+
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
154+
return [];
155+
}
143156
```
144157

145158
</TabItem>
146159

147-
<TabItem value="core_deprecation" label="Using the \core\deprecation API from Moodle 4.4">
160+
<TabItem value="debugging" label="Deprecations using debugging">
148161

149162
```php
150-
#[\core\attribute\deprecated('foobar::blah()', since: '4.4', mdl: 'MDL-XXXXX', final: true)]
151-
public function foobar(int $old, array $params): array {
152-
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
153-
return [];
154-
}
163+
throw new coding_exception(
164+
'foobar() can not be used any more, please use foobar::blah'
165+
);
155166
```
156167

157168
</TabItem>
158169

159170
</Tabs>
160171

161-
- Function and Method signatures **must not change**, that is:
172+
- Method signatures **must not change**, that is:
162173
- keep any existing parameters; and
163174
- keep any existing return type.
164-
- The deprecation 'since' tag should remain as the version where the initial deprecation happened.
175+
- Function signatures _may_ be removed, that is:
176+
- all parameters may be removed; and
177+
- and return type declaration may be removed.
178+
- The deprecation 'since' tag should remain as the version where the _initial_ deprecation happened.
165179
- Deprecated classes must be completely removed.
166180
- The content of the PHPDoc should be removed, leaving only the `@deprecated` tag with the notice and, optionally, the replacement information. This includes all `@param`, `@return`, and other tags, as well as the description.
167181
- External functions deprecation process is different from the standard deprecation and functions should be completely removed.
168182
- Last but not least, every deprecation should be documented in an [upgrade note](../../upgradenotes.md) **at least** once but, **ideally**, both on the initial/immediate deprecation and also on this final deprecation/removal.
169183

184+
### Step 3. Removal
185+
186+
#### Policy
187+
188+
A code removal step was added to the deprecation process in Moodle 5.0 and is aligned with the LTS release cycle.
189+
190+
- Any feature or functionality which went through the Step 2 (Final deprecation) process _before_ an LTS release, may be removed in the next major version _after_ the LTS release.
191+
- Removals must be documented in an [upgrade note](../../upgradenotes.md).
192+
193+
<ValidExample title="Example">
194+
- Functions initially deprecated in Moodle 4.4 (Series 4) and below will be considered for final deprecation in Moodle 5.0 (the first Series 5 Moodle version), and for removal in Moodle 6.0 (the first Series 6 Moodle version).
195+
- Functions deprecated in Moodle 4.5 (LTS) will be up for final deprecation in Moodle 6.0 (the first release for Series 6 right after the Moodle 5.3 (LTS) release), and for removal in Moodle 7.0 (the first Series 7 Moodle version).
196+
</ValidExample>
197+
170198
## Parameters deprecation
171199

172200
Whilst it is possible to deprecate individual method parameters, care must be taken in doing so.

0 commit comments

Comments
 (0)