Project link: https://www.drupal.org/project/captcha_questions
The PA is to maintain and take over D8 branch after porting of the Captcha Questions module. D7 code referred for porting is 7.x-1.x
Code repo: http://cgit.drupalcode.org/captcha_questions/?h=8.x-1.x
Setting up repository for the first time
git clone --branch 8.x-1.x https://git.drupal.org/project/captcha_questions.git
cd captcha_questions
PA Reviews
https://www.drupal.org/node/2757639#comment-11350213
https://www.drupal.org/node/2761937#comment-11377257
https://www.drupal.org/node/2787937#comment-11595321
https://www.drupal.org/node/2680727#comment-11373023
https://www.drupal.org/node/2750971#comment-11327075
https://www.drupal.org/node/2759947#comment-11364903
https://www.drupal.org/node/2758057#comment-11354273
https://www.drupal.org/node/2668938#comment-11369699
https://www.drupal.org/node/2752177#comment-11312413
https://www.drupal.org/node/2706231#comment-11369283
https://www.drupal.org/node/2732319#comment-11312303
https://www.drupal.org/node/2688692#comment-11392841
https://www.drupal.org/node/2718335#comment-11332779
https://www.drupal.org/node/2731465#comment-11365075
https://www.drupal.org/node/2737337#comment-11317177
https://www.drupal.org/node/2756405#comment-11368867
https://www.drupal.org/node/2744019#comment-11365149
https://www.drupal.org/node/2765647#comment-11401015
https://www.drupal.org/node/2763403#comment-11388345
https://www.drupal.org/node/2755901#comment-11341293
https://www.drupal.org/node/2758289#comment-11365213
https://www.drupal.org/node/2756681#comment-11353477
https://www.drupal.org/node/2761459#comment-11373535
https://www.drupal.org/node/2767617#comment-11409095
https://www.drupal.org/node/2742353#comment-11353519
https://www.drupal.org/node/2701221#comment-11393089
https://www.drupal.org/node/2746815#comment-11311979
https://www.drupal.org/node/2796315#comment-11621415
https://www.drupal.org/node/2797043#comment-11648031
https://www.drupal.org/node/2762531#comment-11380527
https://www.drupal.org/node/2758295#comment-11354397
Comments
Comment #2
yogeshmpawarComment #3
yogeshmpawarComment #4
denutkarsh commentedAutomated Review
Review of the 8.x-1.x branch (commit 3191536):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Manual Review:
I saw many calls
$this->config('captcha_questions.settings');for settings values in a method. IMHO store this in a variable and then use it to set values.$this->config('captcha_questions.settings');. JustComment #5
denutkarsh commentedComment #6
yogeshmpawarThanks denutkarsh for the review, will make changes as per comment.
Comment #7
yogeshmpawar@denutkarsh - Changes done as per the comment #4.
"\Drupal calls should be avoided in classes" these are just warnings so they are not a application blocker so i think it will not go in "Needs Work" state.
Please review again & manual reviews are always welcome.
Comment #8
harsh.behl commented@Yogesh Pawar
In CaptchaQuestionsDblogController.php file on line 32 you have used $db = Database::getConnection(); for db connection please use dependency instead of using it in this way.
Comment #9
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpsgitdrupalorgprojectcaptcha_questionsgit
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #10
denutkarsh commented@yogesh-pawar That's what i wanted to say. It is good practice to follow Drupal Practices. I would advise you to fix all the errors and warnings in pareview if possible. Thanks
Comment #11
yogeshmpawar@pen & @denutkarsh - Thanks for the review. i have corrected all warnings mentioned in pareview.sh
Comment #12
yogeshmpawarComment #13
harsh.behl commented@yogesh
Hi I have found some errors in CaptchaQuestionsSettingsForm.php on line 182 & 310 $webform_forms = $this->captchaQuestionsGetWebforms(); in this function you have used select query to load the nids & title of webform node types, if there are no nodes of type webform then it will through errors:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1: SELECT n.nid AS nid, n.title AS title FROM {node} n WHERE (n.type IN ()); Array ( ) in Drupal\captcha_questions\Form\CaptchaQuestionsSettingsForm->captchaQuestionsGetWebforms() (line 341 of modules/captcha_questions/src/Form/CaptchaQuestionsSettingsForm.php).
Please add a check of rowcount or similar before executing this query.
Comment #14
yogeshmpawar@pen - Thanks for your suggestion & nice catch of error, I have checked & removed the error.
Comment #15
yogeshmpawarComment #16
aloknarwaria commentedHi Yogesh Pawar
Great work,
Suggestion:
In your file "captcha_questions.module" you have used the code
recommend you to please use the config object once and the use in your code below like:
Similarly avoid the below code as well
use the code like
Comment #17
yogeshmpawar@aloknarwaria - Thanks for the review & suggestions. i have made changes suggested by you. please review.
Comment #18
yogeshmpawarComment #19
aloknarwaria commentedHi Yogesh Pawar,
Grt work there are some more issues please find below.
1. Error message found.
User error: Invalid placeholder (!form_id) in string: Blocked submission of form with form_id !form_id. Answer given was %answer_given in Drupal\Component\Render\FormattableMarkup::placeholderFormat() (line 235 of /home/d8demo1/web/core/lib/Drupal/Component/Render/FormattableMarkup.php) #0 /home/d8demo1/web/core/includes/bootstrap.inc(548): _drupal_error_handler_real(256, 'Invalid placeho...', '/home/d8demo1/w...', 235, Array) #1 [internal function]: _drupal_error_handler(256, 'Invalid placeho...', '/home/d8demo1/w...', 235, Array) #22. Custom form_id setting breaks when i try to add invalid form id and try to save the configuration.
Comment #20
matthieuscarset commentedHi @yogesh-pawar
Automated test
I've run a new Automated test and there are still 24 ERRORs + 8 WARNINGs:
https://pareview.sh/node/1063
Manual test
I found a bug in the admin page, when you add a custom form name and try to save the configuration.
Steps to reproduce below:
The website encountered an unexpected error. Please try again later.Comment #21
yogeshmpawar@matthieuscarset - Thanks for the review, i have removed that error which breaks the admin page. the automated test which you posted are for 7.x-1.x branch but this project is in 8.x-1.x branch. while checking the pareview.sh you have to mention branch as 8.x-1.x & automated test results are pareview.sh.
@aloknarwaria - Thanks for your observation, i have corrected that error which you mentioned & also corrected the functionality for custom form_id.
Comment #22
navneet0693 commentedUse '%' instead to instead of . Refer here.
Comment can be removed.
Can be reduced to
$config = $this->config('captcha_questions.settings'); $config->get('captcha_questions_watchdog')as you are using$this->config('captcha_questions.settings')more than once :-)Similarly,
$this->config('captcha_questions.settings')can be optimized.A more clear description would be great with a hint for enabling Captcha Questions Dblog module.
base_route: system.admin_contentI am not very sure why it is chosen to appears in here with admin/content local tasks with url as settings route is "admin/config/people/captcha_questions".
If I am not wrong, this isn't the correct way of finding webform ids.
$form_state->setErrorByName('captcha_questions_answer', $this->t('Please provide an answer'));Typo here: *$form['settings']['captcha_questions_answers']*, and if I am not mistaken, but you can use #required as an alternative, until and unless you aren't trying to achieve something else.
I doubt if all the form ids are available ex: contact_site_form, contact_personal_form
Some of the forms available on Drupal 8 vanilla installation:
Webform ids cannot be retrieved by this method.
Multiple calls to
getValue()can be reduced by usinggetValues()* Helper function to make a list of candidates of form ids.Its recommended to keep form clean and move supporting functions either as a service or in module file.
Review of your submodule: Captcha Questions Dblog
File: captcha_questions_dblog.install
$pass_link = \Drupal::l(t('Configure'), Url::fromRoute('captcha_questions_settings'));Use Link function instead on \Drupal::l().
Comment #23
klausi@navneet0693: only use the % placeholder for $this->t() when you have a variable to be into the string. If not then em tags on string literals are fine.
Otherwise those are some nice tips for improvements but surely not application blockers. Anything else that you found or should this be RTBC instead?
Comment #24
navneet0693 commented@klausi None of them are application blockers, the suggestions can be improved later on :-). Marking RTBC.
Comment #25
jeetendrakumar commentedThis module is working fine for me. Great work.RTBC+
Comment #26
yogeshmpawar@navneet0693 - Thanks, as per comment #22, implemented the suggestions.
Comment #27
yogeshmpawarComment #28
yogeshmpawarAssigning Credits.