Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Followup to #2158871: [Policy, no patch] Clearly denote when @deprecated code is slated to be removed
All functions labelled @deprecated should include details about when they were deprecated, when they will be removed and, where possible, what they should be replaced with.
For example:
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Drupal\content_translation\Controller\ContentTranslationController::edit().
Some functions should not be changed at this stage. These are:
- comment_int_to_alphadecimal and comment_int_to_alphadecimal. There is a patch to remove them on #2187653: Remove comment_alphadecimal_to_int and comment_int_to_alphadecimal
- _drupal_add_css and _drupal_add_js. These are private functions and probably shouldn't be deprecated. Issue TBC.
- _menu_get_legacy_tasks. Also a private function. Issue TBC.
See also https://drupal.org/coding-standards/docs#deprecated
Comment | File | Size | Author |
---|---|---|---|
#25 | 2187735-25-deprecated-docblocks.patch | 74.02 KB | ianthomas_uk |
Comments
Comment #1
ianthomas_ukHere's my first pass of the modules folder.
I've tried to keep the format consistent:
- All state '@deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
- Class names are fully qualified.
- The word 'Use' is normally on the second line for easier reading, except when there are multiple possible replacements, where each replacement gets its own line.
- I've removed the word 'instead' where it appears and added full stops to the end of sentences.
- I've removed @see when it just duplicates the information in the @deprecated.
- I've added @see when using \Drupal if an intermediate service is used (as ideally the service should be used directly).
- I've removed suggestions to inject services rather than using \Drupal.
These are all open for discussion, particularly the last point. It was clumsy the way it was being used, but the phrasing I've used makes no reference to dependency injection. Maybe we should link to a doc page about doing this properly?
Comment #2
ianthomas_ukThis patch updates everything currently marked @deprecated, except where mentioned in the issue summary.
It's a big patch, but is very repetitive, so partial reviews are welcome.
Comment #3
andypostAdds code for regression from #1959574-86: Remove the deprecated Drupal 7 Ajax API
EDIT should be commited
Comment #4
ianthomas_uk@andypost this issue is about changing the docblock of functions already marked as @deprecated, I think you may have confused it with another issue.
Comment #5
dawehner@andypost
What about fixing it first in the other issue?
Comment #6
andypost@dawehner, yep, is new issue needed to fix regression?
Comment #7
ianthomas_ukAny thoughts on the patch? It's extremely repetitive, so even a review of one function is useful, as the same thoughts are likely to apply to 90% of the patch.
Comment #8
Sutharsan CreditAttribution: Sutharsan commentedRerolled the #2 patch.
The following functions got removed from core in the meantime:
Review of #2 patch:
Comment longer than 80 chars.
Again
Again
Some 'Use ...' lines end with a period, some don't. Please make consistent.
Comment #9
ianthomas_ukHere's a reroll that removes two more functions that were removed from forum_test.module.
RE #8
1) I'm not sure which line you thought was over 80 chars. There was one that the patch didn't touch, so I've fixed that in passing.
2) I can't see any lines over 80 chars.
3) Fixed.
4) Fixed.
Comment #11
ianthomas_uk9: 2187735-9-deprecated-docblocks.patch queued for re-testing.
Comment #13
Sutharsan CreditAttribution: Sutharsan commented9: 2187735-9-deprecated-docblocks.patch queued for re-testing.
Comment #14
Sutharsan CreditAttribution: Sutharsan commentedJust a minor one: a trailing white space.
Comment #15
jibranWhy some of the functions have @see same as @deprecated and some haven't? Please make it consistent.
more then 80 chars.
More then 80 chars.
Comment #16
ianthomas_uk- Reroll following #2167267: Remove deprecated field_attach_*_view() (interdiff was generated pre-reroll).
- Addresses #14.
- I've removed the full stop from those 81 character lines, as I thought that looked better than wrapping the whole URL.
- Generally relevant classes are mentioned in @return or @deprecated and I don't think it's necessary to duplicated that in an @see. Where a method is a wrapper around a \Drupal method the intermediate handler isn't usually mentioned in the docblock, so an @see will normally be used. I've fixed this in several places, including suggesting \Drupal as a replacement in more places, and moving the old suggested replacement to @see.
- I've removed the change to getContainer(), as I think that's actually private rather than deprecated. See #2160655-24: Improve error handling of \Drupal class
- I'm not convinced the suggested replacements in the various tests in the system module are correct, but I'm just moving around the existing suggestions and I think correcting them is outside the scope of this issue.
Comment #17
dawehnerWe don't add the @see everywhere, but I think this is totally fine.
Note: sometimes we use @deprected and then @see and the other way round. I would think that @see should be above, what do you think?
Note: All those should be actually \Drupal\form_test\Form\FormTestForm::testGroupVerticalTabs() instead, but this is some bug already in HEAD.
Comment #18
ianthomas_ukI've tried to include @see everywhere that it is different from @return or @deprecated. In the example given, @deprecated lists \Drupal::service('date')->formatInterval() and the @see is for \Drupal\Core\Datetime\Date::formatInterval().
I'd probably put @see at the very end of all the comments. But this is already inconsistent across core and I think would add a lot of work to fix for not much benefit.
Comment #19
dawehnerIt is odd that we use @deprecated for tests anyway.
Comment #20
ianthomas_ukThat's a good point. I'll split the tests out into a different issue, as we might want to handle those in a different way and they shouldn't cause updates to documentation of APIs that people are actually using to be delayed.
Comment #21
Damien Tournoud CreditAttribution: Damien Tournoud commentedIs there any reason to mark private functions as deprecated? Those are not supported anyway, so I don't see a need to bother with them.
Comment #22
ianthomas_ukIf other people just want the @deprecated tags to be removed from private functions then I'd be fine with that, but I don't think they are doing any harm.
Strictly speaking we probably don't need them, but they can still be useful to core devs and are something we can check for as we approach 8.0 (i.e. are there any @deprecated functions left? If so, why?). It's also an extra hint that people shouldn't be using these functions.
Comment #23
dawehnerLet's be pragmatic and get it in.
Comment #24
alexpott2187735-20-deprecated-docblocks.patch no longer applies.
Comment #25
ianthomas_ukReroll - just needed to ignore the failed hunk because entity_get_info() has been removed for #1981858: Rename hook_entity_info/alter() to hook_entity_type_build/alter()
Comment #26
ianthomas_ukNeeds another reroll - leave it with me
Comment #27
ianthomas_ukActually, no reroll needed (it was just git getting confused)
Comment #28
alexpottCommitted eb53ecc and pushed to 8.x. Thanks!
Comment #29
dawehnerSadly the fix from andypost got lost again: #2203239: Remove ajax_render and co.