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.
This is a sub-issue of #1800046: [META] Add missing type hinting to core docblocks, fix Drupal.Commenting.FunctionComment.Missing* focused on correctly adding @param and @return type hinting to the Update module.
Documentation patches that include type hinting are time consuming to both review and commit because one must dig into the actual code to confirm that the type hints are both correct and complete. Hence, please be patient and try to limit type hint patches to covering only a limited number of docblocks (20-25 as a guess).
How To Review This Issue
- Attempt to apply the patch to see if it needs a reroll.
- Use the phpcs one-liner to evaluate whether all the relevant standards errors have been resolved: https://gist.github.com/paul-m/227822ac7723b0e90647
- Look at each change and determine whether the type hint is correct.
Related sprint issues:
Comment | File | Size | Author |
---|---|---|---|
#53 | 1811202-53.patch | 16.31 KB | shetpooja04 |
#47 | 1811202-47.patch | 16.09 KB | savkaviktor16@gmail.com |
#40 | interdiff.txt | 21.05 KB | Mile23 |
#40 | 1811202_40.patch | 16.29 KB | Mile23 |
#38 | add_missing_type-1811202-38.patch | 33.79 KB | tatisilva |
|
Comments
Comment #1
bleen CreditAttribution: bleen commentedThis is a patch for update.module ... none of the .inc files are included as to not overwhelm anyone
Comment #2
bleen CreditAttribution: bleen commented...of note:
None of these functions actually return anything
Comment #3
Lars Toomre CreditAttribution: Lars Toomre commentedThanks for this patch @bleen18. From previous experience with wotking with @jhodgdon on these types of documentation issues, she only wants to commit changes that are between /** and */ in issues such as these. Hence, my recommendation would be to split your patch into two parts.
The changes to _update_create_fetch_task(), _update_refresh() and _update_fetch_data() (along with the proposed changes to their docblocks) should go into a new issue to be posted in the Update.module queue. The rest of the patch then should be re-rolled for here.
Comment #4
bleen CreditAttribution: bleen commentedthis removes the changes to "return" lines
Comment #5
bleen CreditAttribution: bleen commented... opened #1818976: Several update functions incorrectly return NULL values for the return statements
Comment #6
Lars Toomre CreditAttribution: Lars Toomre commented@bleen 18 The patch in #4 is for Tracker module, not the Update module. Looks like you uploaded the wrong patch to this issue.
Comment #7
bleen CreditAttribution: bleen commentedoops
Comment #8
Lars Toomre CreditAttribution: Lars Toomre commented@bleen18 I am having a problem getting the new patch like in the other issue. When I try to retrieve 1811202.patch using curl, I am getting the first one (i.e. #1), not the version uploaded in #7.
This common patch name problem is why it is the Drupal 'best practice' to try to create files with unique names like '[issue #]-[comment #]-th-update.patch'. Could you upload #7 again using a unique name so that I can get it download? Thanks in advance.
Comment #9
bleen CreditAttribution: bleen commented@lars Toomre ... you need to look at the actaul link .. in this case the link the second patch is http://drupal.org/files/1811202_0.patch
Comment #10
Lars Toomre CreditAttribution: Lars Toomre commentedAh thanks @bleen18... I did not realize that. I was using simply what shown on the green bar.
How did you get the actual link so I do not bother you again with this type of issue?
Comment #11
bleen CreditAttribution: bleen commentedsimply, right click the link and copy it ... or hover over it, in chrome at least it shows you the destination at the bottom left of your window
Comment #12
Lars Toomre CreditAttribution: Lars Toomre commentedThanks for rolling this patch @bleen18! I am sorry about my confusion in getting this patch down to my local machine.
Here is the start of another nit-picky review. Again, I am focused on making sure we get a resulting RTBC patch that is ready to be committed so that we minimize any push back there, since these type of patches take much time and attention to detail to review correctly and completely.
First, I noted that there are several places in this module where #1487760: [policy, no patch] Decide on documentation standards for namespaced items applies:
- MockFileTransfer.php,
- update.authorize.inc, and
- update.manager.inc.
With this patch locally applied, I see that we are missing many @param type hints:
- two in update.api.php,
- numerous in update.authorize.inc,
- thirteen more in update.compare.inc,
- nine more in update.fetch.inc,
- two in update.install,
- six in update.manager.inc,
- none in update.module, and
- none in update.report.inc.
Additionally, with this patch applied locally, there are missing type hints in the following files:
- one in update.api.php,
- five in update.compare.inc,
- four in update.fetch.inc,
- two in update.install,
- two in update.manager.inc, and
- none in update.module.
Also, checked and with this applied there are no '(Optional)' capitalization issues in this patch.
I am going to save this here and continue with the detailed dreditor comments/review of the patch in the next comment.
Comment #13
Lars Toomre CreditAttribution: Lars Toomre commentedBelow are my detail notes from reviewing the patch in #7:
This type hint is correct in update_manager_access().
Looks like we are missing a @return directive for _update_no_data().
This type hint addition is correct as is the @return type hint for update_get_available().
This type hint is correct in update_create_fetch_task().
We should add array to the function declaration in whatever coding fix issue we use to add array to function declarations.
This type hint addition for _update_get_cached_available_releases() is correct.
All of these type hints for update_mail() are correct.
These type hints in _update_message_text() are correct.
This type hint should be 'string|null' at minimum. Have we double checked that the $langcode is a string and not an integer. I get confused by the language constant definitions.
This type hint is correct.
My understanding is that helper functions for uasort() functions do not require @param or @return directives.
I think I mentioned it elsewhere, but let me repeat. theme() functions should not include a @return directive according to [#1354].
All three of these type hints for _update_cache_set() are correct.
I think this should be 'array|false' since db_query() can return FALSE if the $cid value was not found.
This first one is incorrect. It should be 'string|null'. The second type hint is correct. What do you think?
This type hint is correct.
These type hint additions for _update_manager_extract_directory() are correct.
Both of these type hint additions in _update_manager_cache_directory() are correct.
This type hint in update_delete_file_if_stale() is correct.
Comment #14
Lars Toomre CreditAttribution: Lars Toomre commentedThere is quite a bit already in this patch @bleen18. How would you like to approach the additional items noted in #12? Would you like to add some more to this patch or just leave all of the rest until the follow up patch after this is committed?
I also would appreciate some guidance from @jhodgdon if she looks into this issue. Thanks in advance.
Comment #15
Mile23Comment #16
Mile23Reroll of #7, without any of the issues raised in subsequent comments.
Will work on those.
Comment #17
Mile23This covers all the top-level PHP files in the module, so .install, inc, .module, etc.
Comment #18
Mile23I'd like to draw the reviewer's attention to this, which happened because you're not supposed to document @params and @return values for hooks. However, this information is important.
Comment #20
Mile23The failure seems unrelated (in LockFunctionalTest), so I'll re-run the testbot.
Comment #22
Mile23Related issue: #1987890: Convert update_test_mock_page() to a new style controller
Will work around it.
Comment #23
Mile23This gets everything, I think.
Comment #25
Mile23Kicking testbot...
Comment #28
Mile23Failure related to the fact that type hinting works. :-)
Comment #30
Mile23Gets the remaining implementations.
Comment #31
jhodgdonThis is adding type hints to code. Moving out of documentation component.
Is this really right anyway??!?
Comment #32
Mile23I wondered about that. QueueItemInterface says this:
QueueInterface::claimItem() says this:
claimItem() docs don't look wrong, from looking at Memory::claimItem(). I think the queue system never got fully OOP-ified.
Comment #33
Mile23Comment #34
Mile23Comment #35
Nitesh Sethia CreditAttribution: Nitesh Sethia commentedRerolling
Comment #36
Mile23Bumping to 8.1.x. Patch no longer applies.
Comment #37
Mile23Comment #38
tatisilva CreditAttribution: tatisilva commentedI rerolled. There were merge conflicts. I kept all the changes from HEAD but made sure that type hinting was kept.
Comment #40
Mile23Thanks, @tatisilva.
We're not supposed to be adding code changes here, even though I did it originally. For instance, this shouldn't change, within the scope of this issue:
So only type hinting within
@param
and@return
.Since this is a re-roll of my work, I'll work on it and remove all the changes that need removal.
As @jhodgdon pointed out elsewhere, these issues can be for 8.0.x because they are docs-only.
Reviewer please see #18 because that still applies. Also, I'm not sure where
update_test_mock_page()
came from (see interdiff). Pretty sure it was either a bad re-roll or a bad patch.Comment #46
borisson_This patch no longer applies, @alexpott recently committed something similar for the locale module. Setting to needs work for a reroll.
Comment #47
savkaviktor16@gmail.com CreditAttribution: savkaviktor16@gmail.com at Skilld commentedRe-rolled
Comment #48
idebr CreditAttribution: idebr at iO commentedThese @params violate Drupal.Commenting.HookComment.HookParamDoc (Hook implementations should not duplicate @param documentation) and should be removed.
Undefined class FileTransfer
Undefined class FileTransfer
Comment #53
shetpooja04 CreditAttribution: shetpooja04 at QED42 commentedI have uploaded patch with changes comparing from #47 in 9.1.x version
and also implemented #48.1 point
Please check and mention what changes are required further
used the below to check
phpcs --standard="Drupal" --extensions="module/php,inc/php,php" --report-csv core/modules/update | grep -F $'Missing param\nReturn type missing'
Please review!
Comment #54
shetpooja04 CreditAttribution: shetpooja04 at QED42 commentedComment #56
quietone CreditAttribution: quietone as a volunteer commentedThis work is now being done by sniff. The work here is now in #3207949: Fix Drupal.Commenting.FunctionComment.MissingParamType so closing this as a duplicate. I've identified credit to add over there, let me know if I got it wrong.