This module provides the Yahoo Finance currency exchange rate synchronization provider for Commerce Multicurrency module.
Yahoo! Finance provides financial information and commentary with a focus on US markets and offers currency exchange rates in almost all the available currencies.
Just select the Yahoo Finance sync provider and get the multicurrency work for the site perfectly.
DEPENDENCIES
This module depends on the Commerce Multicurrency module.
Drupal Core version: 7.x
Visit the project page for the usage instructions.
The link to the project is, https://www.drupal.org/sandbox/th_tushar/2308795
The link to the GIT Repository is, git clone --branch 7.x-1.x th_tushar@git.drupal.org:sandbox/th_tushar/2308795.git
The direct link to the GIT Repository for non-maintainer, git clone --branch 7.x-1.x http://git.drupal.org/sandbox/th_tushar/2308795
Manual Reviews:
https://www.drupal.org/node/2308829#comment-8994153
https://www.drupal.org/node/2306817#comment-8994241
https://www.drupal.org/node/2308015#comment-8994375
Comments
Comment #1
th_tushar commentedComment #2
th_tushar commentedComment #3
pushpinderchauhan commented@th_tushar, first of all thanks for contribution!
Your module is so small, as per guidelines for project length and complexity I am tagging "PAReview: Single project promote" tag with this.
Here is my assumptions on your code after manual review:
1.
$ratesvariable is not declared outside 'for loop' as it should be. In any case if$target_currenciesis empty, it would produce notice.2. In following code you have explode the
$recordvariable in$currency_datavariable. Are you sure every time it contains three values in array, if this is not the case then it would produce notice. Best practices to check array count of$currency_datavariable. Also this variable is set through third party response ($record = $http_result->data;), so it would be better you should check response type and use sanitize function before final passing.3. Where you are using
$timestampvariable, please add comment.4. Also add
hook_help()in your module.Thanks Again!
Comment #4
th_tushar commentedHi @er.pushpinderrana,
Thank you for reviewing my module.
1. $rates variable is not declared outside 'for loop' as it should be. - I will declare it outside for loop.
In any case if $target_currencies is empty, it would produce notice. - $target_currencies will not be empty in any case.
2. $record variable in $currency_data variable. Are you sure every time it contains three values in array
Yes, I am sure that it will contain three values. I will validate it to be safe.
3. Regarding $timestamp, I required this variable to save in backend, in further development to maintain historic currency values.
4. I will add hook_help() function.
I need to create a admin features for this module yet, So it will be as per the guidelines for project length. Hence removing the PAReview: Single project promote tag.
Thanks again for your review. :)
Comment #5
th_tushar commentedUpdated the code.
Comment #6
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxth_tushar2308795git
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #7
th_tushar commentedComment #8
mpdonadioAssigning to myself for next review.
Comment #9
mpdonadioAutomated Review
Git default branch is not set, see the documentation on setting a default branch.
Review of the 7.x-1.x branch (commit aa088a4):
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 think both the README and project page need improvements.
(*) It looks like the $active_currency needs to be plained in commerce_multicurrency_yah_getrates_forall on line 365. See https://www.drupal.org/node/28984
(*) It looks like $site_default_currency_name is used unsaniticed on line 371. Use t() with a placeholder here as that string needs to be translated.
You don't need quotes around items in the .info file
I would add commerce as a dependency.
(+) The namespace in your css should match the namespace of your module.
Avoid linebreaks in the strings passed to t() (eg, commerce_multicurrency_yah_help). It makes translation harder. Don't linewrap these just to appease PAReview.
(+) Your permission names should be more closely aligned with your module name. What is there is an unrelated module that integrates with Yahoo! finance?
The access arguments in commerce_multicurrency_yah_menu() are specified twice.
(+) The namespaces in commerce_multicurrency_yah_theme() should be more closely aligned with your module name.
The paragraph in the output of theme_yahoo_fin_currency() isn't needed.
(+) theme_yahoo_fin_link() should build the URL paramaters via the options to l() and not manually.
Is commerce_multicurrency_yah_commerce_multicurrency_exchange_rate_sync_provider_info() a hook? If so, it needs a proper docblock.
The type signature of commerce_multicurrency_yah_form() is wrong if that is a proper Drupal form. It should be commerce_multicurrency_yah_form($form, &$form_state).
(*) Why the use of $_SESSION in commerce_multicurrency_yah_form() and commerce_multicurrency_yah_form_submit()? Comment needed. Or maybe you just need to use
$form_state['values']? I don't quite understand this. In general, the use of $_SESSION in Drupal form handling should be avoided, especially if the variables you
are setting stay within the form. I am marking this as a blocker, as it looks like a big bypass of the Form API.
In commerce_multicurrency_yah_form() you have some places where you create #markup and then call theme(). Don't do this. Use the #theme element and build
up a proper render array.
In commerce_multicurrency_yah_getrate(), but up the URL parameters with drupal_http_build_query() instead of manually.
commerce_multicurrency_yah_getrates_forall() needs a proper docblock.
I think commerce_multicurrency_yah_getrates_forall() should return a proper render array and not themeed output directly?
In commerce_multicurrency_yah_settings_form(), the variable_get needs a default value.
Since you need to set variables other than what your module provides, commerce_multicurrency_yah_settings_form() isn't a system settings form? I think this needs to be commented.
(+) commerce_multicurrency_yah_settings_form() has some untranslated strings (eg, line 30). Double check the module.
You should avoid directly creating HTML element IDs. You can probably just use classes.
(+) You need a hook_uninstall to variable_del() the variables you are creating.
Avoid double spaces in strings to be translated, eg line 134.
In theme_yahoo_fin_currency on line 131, I think !isset won't catch all of the cases you need. empty() may be better here, thouch empty() doesn't work for floating point per the manual.
In commerce_multicurrency_yah_form, line 216, you have an untranslated string. Use t() and pass the URL as a placeholder.
In commerce_multicurrency_yah_form_validate(), just mark the element as required instead of using a validator. And, for $form['amount'] set an element level validator and use element_validate_number().
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
Comment #10
th_tushar commentedHi @mpdonadio,
Thanks for taking time to review my module.
I have fixed all the issues pointed by the automated review tool and also the issues mentioned in the manual review.
Secure code
No. If "no", list security issues identified.
(*) It looks like the $active_currency needs to be plained in commerce_multicurrency_yah_getrates_forall on line 365. See https://www.drupal.org/node/28984 - Fixed, function name changed to commerce_multicurrency_yah_display_rates(). (more appropriate).
(*) It looks like $site_default_currency_name is used unsaniticed on line 371. Use t() with a placeholder here as that string needs to be translated. - Fixed.
Coding style & Drupal API usage
You don't need quotes around items in the .info file
I would add commerce as a dependency. - Done.
(+) The namespace in your css should match the namespace of your module. - Maintained the namespace.
Avoid linebreaks in the strings passed to t() (eg, commerce_multicurrency_yah_help). It makes translation harder. Don't linewrap these just to appease PAReview. - Taken care of it.
(+) Your permission names should be more closely aligned with your module name. What is there is an unrelated module that integrates with Yahoo! finance? - Changed the permission names to relate to the module.
The access arguments in commerce_multicurrency_yah_menu() are specified twice. - Fixed.
(+) The namespaces in commerce_multicurrency_yah_theme() should be more closely aligned with your module name. - Taken care of it.
The paragraph in the output of theme_yahoo_fin_currency() isn't needed. - Done.
(+) theme_yahoo_fin_link() should build the URL paramaters via the options to l() and not manually. - Fixed.
Is commerce_multicurrency_yah_commerce_multicurrency_exchange_rate_sync_provider_info() a hook? If so, it needs a proper docblock. - Done.
The type signature of commerce_multicurrency_yah_form() is wrong if that is a proper Drupal form. It should be commerce_multicurrency_yah_form($form, &$form_state). - Fixed.
(*) Why the use of $_SESSION in commerce_multicurrency_yah_form() and commerce_multicurrency_yah_form_submit()? Comment needed. Or maybe you just need to use
$form_state['values']? I don't quite understand this. In general, the use of $_SESSION in Drupal form handling should be avoided, especially if the variables you
are setting stay within the form. I am marking this as a blocker, as it looks like a big bypass of the Form API. - Fixed, removed the $_SESSION and using the $form_state['storage'] to store the submitted values.
In commerce_multicurrency_yah_form() you have some places where you create #markup and then call theme(). Don't do this. Use the #theme element and build up a proper render array. - Done.
In commerce_multicurrency_yah_getrate(), but up the URL parameters with drupal_http_build_query() instead of manually. - Done.
In commerce_multicurrency_yah_settings_form(), the variable_get needs a default value. - Done.
(+) commerce_multicurrency_yah_settings_form() has some untranslated strings (eg, line 30). Double check the module. - Done.
(+) You need a hook_uninstall to variable_del() the variables you are creating. - Done.
Avoid double spaces in strings to be translated, eg line 134. - Done.
In theme_yahoo_fin_currency on line 131, I think !isset won't catch all of the cases you need. empty() may be better here, thouch empty() doesn't work for floating point per the manual. - Done.
In commerce_multicurrency_yah_form, line 216, you have an untranslated string. Use t() and pass the URL as a placeholder. - Done.
Updating the status to Needs Review.
Comment #11
klausiReview of the 7.x-1.x branch (commit 5127e7b):
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:
But otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Assigning to mpdonadio as he might have time to take a final look at this.
Comment #12
th_tushar commentedHi @klausi,
I have updated the code for the issues pointed in your manual review. Thanks for reviewing my module.
Reviewed other modules,
https://www.drupal.org/node/2316969#comment-9041829
https://www.drupal.org/node/2311531#comment-9042415
https://www.drupal.org/node/2316587#comment-9042437
So, adding the PAReview: review bonus tag.
Comment #13
mpdonadioFixed tags.
Comment #14
mpdonadio(+) You have a few t() calls with linebreaks (commerce_multicurrency_yah_settings_form_submit, line 96, 100 and elsewhere). This makes translation harder. Do a pass through the module before stable release.
theme_commerce_multicurrency_yah_link() has some commented out code; remove it.
My blocking issues from #9 look like they have been addressed. Nothing else jumped out at me.
Comment #15
mpdonadioThanks for your contribution, th_tushar!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #16
th_tushar commentedHi @mpdonadio,
Thank you for your valuable suggestions and efforts in reviewing the module. I will surely check for the #14 before stable release.
Thanks!