Closed (won't fix)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Mar 2011 at 23:53 UTC
Updated:
2 Nov 2013 at 15:41 UTC
Jump to comment: Most recent
Comments
Comment #1
avpadernoComment #2
meba commentedThis needs work and I would like to resort to someone else to decide if this shouldn't be a code snippet instead of module...
- You are using variables in your SQL query. In this case it's fine but potentially, you are exposing your module to SQL Injection. Not good, please look at http://drupal.org/writing-secure-code
- In the part where you display $nb... 'total', you are not using t() function and your code is not translatable. In this case, you need both format_plural() and t().
Comment #3
ronline commentedThx for the review meba.
There are two modifications on the way:
1. The SQL fix and format_plural() implementation.
2. Custom visibility settings to let admin include / exclude the pages where counter shows up.
Comment #4
ronline commentedSql query fixed, format_plural() implemented.
Working on custom visibility settings.
Comment #5
ronline commentedI've added custom visibility settings => settings/uc_purchase_counter.
Webmaster can include / exclude pages where purchase counter appear.
All has been tested with classic drupal paths ?q=node/id, clean urls, URL aliases and taxonomy paths.
Comment #6
tr commentedThere are lots of coding/documentation standards problems. Start by removing all the $Id$ and all the tabs, then adding doxygen comment blocks to all your functions. Read http://drupal.org/coding-standards and apply all those rules to your module. Run the Coder module to look for any remaining coding standards issues.
Also, your repository is structured wrong. You should not have all the code in a "uc_purchase_counter" directory - it should all be top-level.
Comment #7
ronline commentedRemoving all tabs, white spaces and $Id$ tags, documenting functions, adding missing @return directives. The coder module with severity warning level “minor” shows “No Problems Found”.
Repository structure was moved to the top level.
Thanks for your time TR!
Comment #8
ronline commentedIs anybody free to have a look?
Comment #9
ronline commentedbump ...
Comment #10
jpontani commentedAll your functions have indentation issues.
Make sure each new level has 2 spaces indented from the parent indentation, ie the following:
should be:
Inline comments should use //, not /**/ and span multiple lines. If it spans multiple lines, just use // on each successive line (see http://drupal.org/node/1354#inline)
The following code makes no sense, as you initially set $nbp with format_plural, but then overwrite it.
If you're wanting something basic to take advantage of format_plural, I would suggest the following:
$nbp = format_plural($total, '1 purchase', '@count purchases');Other than those, I don't see anything else at the moment.
Comment #11
ronline commentedFixing indentation issues and comment standards, cleaning up the format_plural function.
Comment #12
jpontani commentedSetting to review. Will get back to this when I get a chance.
Comment #13
doitDave commentedHi!
Automated review (Please keep in mind that this is primarily a high level check that does not replace but, after all, eases the review process. There is no guarantee that no other issues could show up in a more in-depth manual follow-up review.)
It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Review of the master branch:
This automated report was generated with PAReview.sh, your friendly project application review script. Go and review some other project applications, so we can get back to yours sooner.
HTH, dave
Comment #14
ronline commentedMoving the master branch into version 6.x-1.x.
Code checked with severity level “minor”. The only warning I got is about drupal_eval function. I need some explanation about this:
I use the drupal_eval to evaluate custom visibility settings. This is a standard procedure used by all drupal modules => block, css_injector, ctools, finder, views …. Coder is throwing warning not only on mine but all above mentioned modules. Should be this warning taken seriously ?
Comment #15
klausiThere are still files other than README.txt in the master branch, make sure to remove them. See also step 5 in http://drupal.org/node/1127732
There is a git tag that has the same name as the branch 6.x-1.x. Make sure to remove this tag to avoid confusion.
Comment #16
misc commented@ronline has been contacted to ask if the application is abandoned.
http://drupal.org/node/894256
Comment #17
ronline commentedI am having problem with git “connect to host git.drupal.org port 22: Connection timed out”. I will get back to comment #15 as soon as I solve the repository issue. Thx for your time guys.
Comment #18
tr commented@ronline: If you ask in the #drupal-gitsupport IRC channel, I'm sure someone will be able to help you resolve your git problem.
Comment #19
ronline commented@comment-15
I have cleaned up master branch and removed the confusing 6.x-1.x tag.
Changes has been pushed up to git
Comment #20
thursday_bw commentedI see you have had this under review for over 12 months, so I'll do my bit to help push this through.
You have a few coding standards errors.. This is the easiest thing to overcome in the review process, keeping on top of it will stop delays in the review by easily avoiding things that all the reviews check first:
see http://ventral.org/pareview/httpgitdrupalorgsandboxronline1095418git
There has been alot of work done to drupalcs of late, so it's good to keep your copy updated because new errors often get found that weren't being checked for previously. This is likely especially annoying for you over a 12 month review process
Manual Review
1. You have minor grammatical issue in on line 2 of uc_purchase_counter.info "Shows number of purchase per product" should be "Shows number of purchases per product" It may be a good idea to work on the wording of this a little.
2. function uc_purchase_counter_form_alter does not appear to be checking the $form_id and and will be modifying all forms; consider user hook_form_FORM_ID_alter instead.
3. Consider using single quotes instead of double quotes, or perhaps a heredoc or nowdoc syntax to assign the long help string to the $output variable in function uc_puchase_counter_help, for readability, it also offers an better code efficiency however very minor.
Also on this string the concatenation of . "
" seems surpurfluous and can be included in the previous string; Yeah I can see that it's efficient because the rest is pass through t() but you already have html in there anyway, what is 3 chars compared to readability?
4. Add a uc_purchase_counter.install file with a hook_unistall with code to delete your rules_page and rules_options drupal variables.
Cheers
Comment #21
ronline commentedFixing minor grammatical issue. Replacing double quote with single quotes. Adding uc_purchase_counter.install file with a hook_unistall.
I need some advice for number 3 requirement in comment 20.
I am not using hook_form_FORM_ID_alter because its working structure is “ uc_product_add_to_cart_form_nid”.
The nid change per product so if I use “hook_form_FORM_ID_alter”, I will have to write function for each product.
EX: The product with node_id 742 need a function “uc_purchase_counter_form_uc_product_add_to_cart_form_742_alter”. The shop has few hundred of products …...
My walk around is to strip the numeric id and check the presence of “ uc_product_add_to_cart”. This is done in uc_purchase_counter.module at line 24.
The function modifies only the forms that belongs to products. It has been tested in the comment #5.
Please feel free to let me know if there is a more convenient way to do this.
Comment #22
miksan commentedHi ronline
You still have some code format errors:
http://ventral.org/pareview/httpgitdrupalorgsandboxronline1095418git
I will look into the code in order to give a manual review.
You still have the master branch. Please delete it to avoid confusion among reviewers about where the "real" version of code is.
Here is some guidelines to delete master branch and set the default branch:
Set default branch to 6.x-1.x: http://drupal.org/node/1659588.
Remove the master branch, see also step 6 and 7 in http://drupal.org/node/1127732
Comment #23
klausiMinor coding standard issues are not application blockers.
Comment #24
miksan commentedWhen I install the module I get following warning:
The table uc_order_products does not exist because the module: "uc_order" has not been installed.
I guess it would make sense to add another line to the .info file:
Another choice (which make less sense) would be to make a check in uc_purchase_counter_form_alter (line 10) if the tables needed exist.
Like:
Comment #25
miksan commentedfunction uc_purchase_counter_form_alter:
Instead of checking the form id in the end of the function and thereby running code and db call on every single form on the site I would move the check to the beginning.
Through the function you have variables that are only used once. You can minimize the code by not declaring the variables first.
You declare the variable $total twice and that is in general not good practice.
Here are my suggestions:
Comment #26
meba commentedYou are using "user access" as Access Check in hook_menu(). This means anyone can access the settings = insecure, especially since you are allowing PHP code evaluation in the settings. Why don't you make the whole thing a block and use core visibility settings for blocks?
Comment #27
misc commentedAdding security tag.
Comment #28
ronline commentedCleaning up the syntax with drupal code sniffer bash script.
Adding missing uc_order dependency into info file.
Changing the default repository branch to 6.x-1.x.
Taking off the user access callback and implementing user_access() control.
Comment #29
martin mayer commentedComment #30
martin mayer commentedI'm afraid that this is a totally wrong usage of the menu API, please re-read the documentation about hook_menu() and how to properly use the 'access callback' functionality.
http://api.drupal.org/api/drupal/developer!hooks!core.php/function/hook_...
Comment #31
ronline commentedFixing 'access callback' functionality.
Comment #32
cubeinspire commentedHi,
Ronline, sorry but I don't understand what is this module for or how to make it work and the description isn't helping much...
The only place where you seem to output content is making a hook_form_alter of uc_product_add_to_cart_form. Where is this form ? How to display it ?
Without knowing what this module does I can only see an evil drupal_eval applied to the data entered by an user into a textarea without any kind of parsing...
Review
.module file line 11:
if (drupal_substr($form_id, 0, 27) != 'uc_product_add_to_cart_form') {This works but it's a bit complicated when you could simply use:
if ($form_id === 'uc_product_add_to_cart_form') {.module line 126:
I don't get why you make a drupal_eval() using as param the content of that textarea...
this textarea is supossed to contain a list of paths but NO PHP code.
You should really remove that function to get this approved or explain well why you want to use it.
Comment #33
ronline commentedThank you for your review logicdesign the module shows the number of purchase per product. It shows up just next to the “Add to card” button.
I have implemented this option to a website of my client. Later I I saw few posts on ubercart website asking for this feature so I put it all in to a module.
However, in these day I am in full time studies and I will not have time to take care of this anymore. I am closing the project and changing the status to “won't fix”
Thanks to all those who helped with review.
Comment #34
tr commented@logicdesign: When reviewing modules like this which are add-ons to large packages (Ubercart in this case), it's necessary to have at least some familiarity with the large package involved.
Specifically, your advice about the uc_product_add_to_cart_form is wrong and misguided. Every product node has it's own add_to_cart_form, with a name uc_product_add_to_cart_form_{nid} where {nid} is the node id for that product. So the applicant's code is not only correct but it's also optimal. @logicdesign: What you suggest is just wrong in this case.
Likewise, the purpose of this module is immediately clear to anyone with some Ubercart experience.
I acknowledge that the applicant is not interested in pursuing the issue.
I'm only bringing this up @logicdesign because of your expressed desire to become a project application administrator. I want YOU to be aware that administration and review of project applications such as this require specialized knowledge and should not be undertaken superficially.
Comment #35
cubeinspire commentedI'm reading it again and I see this review was wrong.
Thank you to point it out, I will be much more careful in the future.
Comment #36
PA robot commentedClosing due to lack of activity. Feel free to reopen if you are still working on this application (see also the project application workflow).
I'm a robot and this is an automated message from Project Applications Scraper.