Follow-up to #2873395: [meta] Add @internal to core classes, methods, properties
Problem/Motivation
https://www.drupal.org/core/d8-bc-policy#controllers
Core modules contain many route controllers that are bound to individual routes, as well as form classes. These form classes are not part of the API of the module unless specifically marked with an @api tag on the method or class.
Proposed resolution
Add @internal tag to the Form Classes.
Add @internal tag to the tests Form Classes.
After discussion it has been decided to not add the @internal tag on the following case:
- abstract Form Base classes which are a part of the API.
ContentEntityFormandEntityForm. Examples module suggests to extend them.
As an exception of this rules, we keep the tag in the EntityDeleteForm. Examples module suggests to use EntityConfirmFormBase (config entity) and ContentEntityConfirmFormBase (content entity).
How to fix this issue
- Read the description for a category in its issue
- Identify and confirm an example. Ask in IRC if unclear.
- Search core for the relevant category.
- Add @internal per the backwards compatibility policy.
- Reviewers should confirm that each @internal mention is appropriate for that category according to the policy.
Remaining tasks
Make the Patch and post it
User interface changes
None.
API changes
There should be no implicit API changes.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | 2873696-21.patch | 137.21 KB | gido |
| #19 | 2873696-19.patch | 132.61 KB | wengerk |
| #17 | 2873696-12.patch | 141.04 KB | wengerk |
| #11 | 2873696-11.patch | 142.53 KB | jofitz |
| #7 | edit_add_internal_to-2873696-7.patch | 143.07 KB | nvexler |
Comments
Comment #2
naveenvalechaComment #3
nvexler commentedHello! I'm at #drupalcon baltimore and I'm working on this issue :). I've talked to @naveenvalecha and @eojthebrave about how important this issue is and how it's a very high priority. So far I have a working copy that I've made a short while ago https://github.com/nathanv/core. I'll be doing my work there in a branch https://github.com/nathanv/core/tree/edit_add_internal_to-2873696 . Feel free to come help me there. I'm hanging out in 301 in the Conference Centre and also in #drupal-docs on irc.
Comment #4
nvexler commentedHello! I have here a WIP. It's probably almost done. I did a tonne of work somewhat quickly so I might have missed some style stuff. I'm uploading it now but will be checking it over right away.
My method was to do the following:
lib/Drupal/Core/Form/FormBase.phpand hovered my mouse over the editor gutter which displays the indicator that the class has subclasses.@internalpiece. When there was no docblock, I created one. I hope they are all ok. If not, I am happy to reroll as necessary.Comment #5
nvexler commentedComment #7
nvexler commentedSorry folks... wrong process here for creating patches... I pulled down just core instead of all of Drupal. This should work.
Comment #8
nvexler commentedComment #9
xjmThanks @nvexler! Excellent work documenting your specific process for further contributors.
Comment #10
wim leersThis no longer applies unfortunately. Which makes reviewing this quite hard. This is looking wonderful already though!
Comment #11
jofitzBundleModerationConfigurationForm has been removed since the patch in #7 was created (see #2843083: Select entity type / bundle in workflow settings).
Re-rolled.
Comment #13
gido commentedI'will help with this one during DrupalCon Vienna
Comment #14
wengerkWorking on it during the DrupalConEU Vienna.
Comment #15
valthebaldTagging
Comment #16
mradcliffeAre *FormBase classes internal? I thought that all/most base classes were a part of the API.
The following abstract base classes are marked as internal in the patch above.
Additionally the following abstract classes might be considered part of the API because they are abstract:
The following base form class is in form_test only and I think that is fine to be @internal.
Please review and discuss these to make sure that we actually want to make them @internal
Comment #17
wengerkThe previous patch in #11 not apply on 8.5.x for multiple reasons:
The new patch 2873696-12.patch is based on the commit b4ce4af60c and should works now.
Here why the previous patch didn't applied:
core/modules/system/src/Tests/Form/StubForm.phphas been removed.core/modules/outside_in/src/Block/BlockEntityOffCanvasForm.phphas been removed.core/modules/statistics/src/StatisticsSettingsForm.phphas changed since the previous patch.core/modules/system/src/Form/CronForm.phphas changed since the previous patch.Comment #18
valthebaldValid point, base forms should not be marked internal per description in the parent issue
Comment #19
wengerkAs suggested by @mradcliffe in #16 & discuss with @valthebald & @gido, we remove the @internal tag on the abstract Base classes but keep them on:
core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBaseWe suggest to also not tag as @internal the following classes:
core/modules/user/src/AccountFormDrupal\Core\Entity\ContentEntityFormDrupal\Core\Entity\EntityDeleteFormDrupal\Core\Entity\EntityFormComment #20
mradcliffeI agree, @wengerk. I looked at Examples module, which suggests extending ContentEntityForm and EntityForm.
The exception might be for EntityDeleteForm. Examples module suggests to use EntityConfirmFormBase (config entity) and ContentEntityConfirmFormBase (content entity).
Comment #21
gido commentedI updated the patch and made a review. I found and tagged the following new Form classes in 8.5x:
Drupal\form_test\Form\FormTestRadiosCheckedFormDrupal\ajax_forms_test\Form\AjaxFormsTestImageButtonFormDrupal\ajax_forms_test\Form\AjaxFormsTestAjaxElementsFormDrupal\Tests\system\Functional\Form\StubFormDrupal\form_test\Form\FormTestOptionalContainerFormDrupal\media\MediaTypeFormDrupal\media\MediaFormDrupal\media\Form\MediaTypeDeleteConfirmFormDrupal\media\Form\MediaDeleteMultipleConfirmFormremoved tag from
ContentEntityFormandEntityForm.Comment #22
mradcliffeIf you have a neighbor looking to help, they could add an explanation of form classes as discovered by @wengerk, @gido and @valthebald above that are not marked as @internal to the issue summary under the proposed resolution section.
Comment #23
wengerkAs suggested by @mradcliffe, I updated the Proposed Resolution section.
Comment #24
gido commentedJust for documenting the way I reviewed the patch:
Drupal\Core\Form\FormBaseComment #25
valthebald1. Removed "Needs issue summary update" because issue summary is updated in #23
2. Repeated steps outline in #24 and ensured that all child classes (with exceptions) now have @internal tag
3. Moving to RTBC
Comment #26
catchCommitted ee0f806 and pushed to 8.5.x. Thanks!
Comment #28
xjmGreat work on this, everyone!
Added credit for valthebald for mentoring
Comment #30
avpaderno