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.
hook_captcha() documentation is lacking proper documentation and the API file has incorrect naming, too.
Todo:
- Rename
captcha_api.txt
tocaptcha.api.php
- Add $captcha_sid argument to the documenation and explain what it does. Not only explain that it exists and is an optional argument. It is not clear what it is made for, how it works and how unique it is.
Comment | File | Size | Author |
---|---|---|---|
#65 | 2548049-65.patch | 763 bytes | shubham.prakash |
| |||
#59 | document_all_arguments-2548049-59.patch | 815 bytes | yogeshmpawar |
| |||
#59 | interdiff-2548049-55-59.txt | 524 bytes | yogeshmpawar |
#55 | document_all_arguments-2548049-55.patch | 652 bytes | yogeshmpawar |
| |||
#43 | document_all_arguments-2548049-43.patch | 13.9 KB | yogeshmpawar |
|
Comments
Comment #2
wundo CreditAttribution: wundo at Chuva Inc. for Chuva Inc. commentedI slightly disagree about the steps that should be taken here, I'd suggest:
Comment #4
rashid_786 CreditAttribution: rashid_786 as a volunteer commentedcaptcha_api.txt renamed as api.md
Comment #5
rashid_786 CreditAttribution: rashid_786 as a volunteer commentedComment #8
elachlan CreditAttribution: elachlan commentedLast step "Create a proper captcha.api.php"
Comment #9
hass CreditAttribution: hass commentedThat is not correct. Hook_captcha has an undocumented 3rd argument and I need to know how this works.
Does drupal .htaccess block requests to .md files?
Comment #10
Dinesh18 CreditAttribution: Dinesh18 as a volunteer and at TATA Consultancy Services commentedComment #11
Dinesh18 CreditAttribution: Dinesh18 as a volunteer and at TATA Consultancy Services commentedI have checked the core modules and we need to remove the docs folder. we need to add the file captcha.api.php inside the captcha module folder. Also, I don't think we need to add any .md files in this folder.
An optional additional argument $captcha_sid with the captcha session ID is available for more advanced challenges (e.g. the image CAPTCHA uses this argument, see image_captcha_captcha()) and it is used for every session. Strictly speaking, it is not necessary to send the CAPTCHA session id with the form, as the one time CAPTCHA token is enough. However, we still send it along, because it can help debugging problems on live sites with only access to the markup.
Comment #13
Dinesh18 CreditAttribution: Dinesh18 as a volunteer and at TATA Consultancy Services for Pfizer, Inc. commentedUpdated Patch.
Comment #14
hass CreditAttribution: hass commentedThis does not document the 3rd param of hook_captcha() what I mainly asked for.
Comment #15
naveenvalechaBumping to normal as its only related to documentation.
Comment #16
chishah92 CreditAttribution: chishah92 at Blisstering Solutions commentedComment #17
chishah92 CreditAttribution: chishah92 at Blisstering Solutions commentedRerolled the patch
Comment #19
hass CreditAttribution: hass commentedThe 3rd param of the hook_captcha() is still not documented and the MAIN reason why I opened the case as I do not understand it at all.
Comment #20
andriyun CreditAttribution: andriyun at Skilld, Drupal Ukraine Community commentedComment #21
elachlan CreditAttribution: elachlan commentedComment #22
naveenvalechaAssuming documentation will not block the release.
Comment #23
naveenvalechaThis issue need documentation changes.So it's more of a task rather than bug.
Comment #24
yogeshmpawarComment #25
yogeshmpawarDocumented all arguments & fix the broken documentations.
Comment #27
yogeshmpawarUpdated patch, removed the Cl error.
Comment #28
yogeshmpawarsame patch again for testing against boat.
Comment #30
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedIt shouldn't be code component I guess. Documentation component is not listed so changing it to Miscellaneous.
Comment #31
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #34
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedSo, if we are renaming captcha_api.txt to captcha.api.php, we need to make sure we have all syntax right.
21:36:31 PHP Parse error: syntax error, unexpected '.' in /var/www/html/modules/contrib/captcha/captcha.api.php on line 120
What's happening is DrupalCI is trying parse the file, and fails due to syntax errors as it considers it to a valid php file.
@Yogesh Pawar You might have to make the syntax right in file, specially convert this to string:
Also you might have to club the examples of hooks implementation as there are multiple declarations. You can track syntax errors by using command:
php <filename>
Comment #35
utkarsh_malviya CreditAttribution: utkarsh_malviya as a volunteer commentedI am a novice. Can someone help me to fix this?
Or is this assigned to someone else?
Comment #36
utkarsh_malviya CreditAttribution: utkarsh_malviya as a volunteer commentedAs someone is working on this issue! Can someone please redirect me to some novice unassigned issue?
Comment #37
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commented@utkarsh_malviya Pick up documentation bugs on contributed modules as beginner :)
Comment #38
yogeshmpawarThanks @navneet0693 for your comment #34.
please review this updated patch.
Comment #40
yogeshmpawarYet another patch to remove Cl error.
Comment #41
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedLet's not leave any stones unturned.
Indentation needs to be clear.
Nice work! Rearranging the implementation examples were indeed needed.
Comment #42
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #43
yogeshmpawarThanks @navneet0693. Changes done as per comment #41
Comment #44
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedGood to go now :)
Comment #46
naveenvalecha@elachlan, Did you forget to update the status?
Comment #47
hass CreditAttribution: hass commentedAs noted several times in this case
hook_captcha()
has an undocumented 3rd argument and I need to know how this works. THIS was the ONLY reason why I opened this case.Comment #48
naveenvalecha@hass,
Thanks for opening that. Please open a new issue for 7.x
As per BC policy https://www.drupal.org/core/backport-policy#d7
Comment #49
yogeshmpawarComment #50
hass CreditAttribution: hass commentedThis is not needed. This is the way how we handle issues for ages.
Comment #51
yogeshmpawar@hass - i have created a child issue which applies on the branch 7.x-1.x-dev as per comment #48. Issue link #2842669: [D7] Document all arguments to hook_captcha() and fix broken documentation.
Comment #52
hass CreditAttribution: hass commentedReviewed D8 again and the 3rd argument still exists in code, but is not documented. So D8 is not fixed here!
Comment #53
hass CreditAttribution: hass commentedWe use @param to document APIs.
Captcha SID param is not documented and missing in the function call.
Comment #54
yogeshmpawar@hass - i got your point, will change this & update the patch now.
Comment #55
yogeshmpawarUpdated patch as per comment #53
Comment #56
naveenvalechabumping its priority to normal
Comment #57
hass CreditAttribution: hass commentedWhat is captcha session ID for and how does it work and what do I need to do as developer when I use it and how should I use it or for what. Nothing answered here. This is not helpful.
Comment #58
elachlan CreditAttribution: elachlan commentedHass, I spent some time going through the code and as far as I can see this is what the $captcha_sid does.
I'll leave it up to yogesh to do up another patch.
Comment #59
yogeshmpawarThanks @elachlan & @hass for the help to improve captcha.api.php, updated the patch as per comment #58 & #57
Comment #60
elachlan CreditAttribution: elachlan commentedThere is a spelling mistake in there. It should say "such as its solved status."
We also need more information on how to use it. For instance because its unique to the session, image captcha uses it for a "static" url for the images for the captcha. The URL remains the same, but the image code changes.
I think @hass would agree that it is really up to the developer how they want to use the $captcha_sid, but at its base it really just uniquely identifies a session.
Comment #61
elachlan CreditAttribution: elachlan commentedComment #62
hass CreditAttribution: hass commentedI agree, this is still totally unclear to me.
Comment #63
couturier CreditAttribution: couturier as a volunteer commentedComment #64
joachim CreditAttribution: joachim commentedI'm not sure I understand how this issue is working, as several commits seem to have been made but it's still in 'needs work'.
At any rate, there is an error in several of the hooks in the api.php file:
The function name must start with 'hook_', not 'foo_'.
This breaks analysis tools such as the API module and Module Builder.
Comment #65
shubham.prakash CreditAttribution: shubham.prakash at OpenSense Labs commentedChange made as per #64
Comment #66
AnybodyCould someone please help with review here to get this fixed? I guess this also needs a reroll. Perhaps as MR then?
Comment #67
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedComment #68
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedI agree with @joachim in #64, I will create a new issue to fix the remaining issues.
CLOSED, duplicate of #3322230: Fix problems inside "captcha.api.php"