Closed (fixed)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
21 Feb 2012 at 14:45 UTC
Updated:
19 Mar 2015 at 22:00 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tinker commentedHere's an automated review of coding format: http://ventral.org/pareview/httpgitdrupalorgsandboxsplatio1334264git
Mainly whitespace issues at the end of lines. You can setup many IDE's to trim these automatically. Let me know what program you are using to code and I might be able to direct you to configuration pages.
Comment #2
msmithcti commentedThanks for the review, all errors and warnings are now fixed.
I'm using netbeans and ended up removing the whitespace using find and replace.
Comment #3
iler commentedYou should have the description in .info file on one row. Now it is on two rows and because of this the module shows under Other instead of Commerce (contrib).
In checkout when I have entered my message which is 'Testing' and press submit I get this error:
EntityMetadataWrapperException: Unknown data property commerce_giftwrap_message. in EntityStructureWrapper->getPropertyInfo() (line 339 of /var/www/commerce.dev/profiles/commerce_kickstart/modules/entity/includes/entity.wrapper.inc).I enabled module, used default settings for gift wrap message and then made order in normal way.
Comment #4
msmithcti commented@iler Thanks for reviewing - I've shortened the description to one line and the module now appears under Commerce (contrib).
As for the error you were getting I've been unable to reproduce it. Did the order already exist when you enabled commerce_giftwrap? Do you have any other modules enabled that are taking part in the checkout process?
Comment #5
tinker commentedSorry I meant to do a full review but got tied up. Your code looks very good. Unfortunately I too am getting the same error message as reported by @iler on a clean install using all the latest required modules.
Some other tiny things to consider:
commerce_giftwrap_delete_giftwrap_line_items()
- $line_item_id does not have a default value if there are none; before you check if its empty. Whilst you don't need to initialise variables it is good practice to do so.
- You also have a check for the $line_item_id in a 'foreach' statement. If you only expect one value you should 'break' the 'foreach' loop when you get one. This happens is a couple of places. Why waste the extra cycles when you have what you want.
commerce_giftwrap_pane_checkout_form($form, $form_state, ...
$form_state should be &$form_state - again you're not using it but it might come into play. You have it right in all the other functions in the checkout_pane.inc file.
Comment #6
tinker commentedHere's my module list:
Product existed before your module was enabled. Order did not exist.
Comment #7
tinker commentedComment #8
iler commentedSame for me as for @tinker. Using latest versions of modules and product existed before this module was enabled but order did not exist.
Comment #9
msmithcti commentedThanks for the suggestions @tinker - they should all be implemented now.
As for the error, it turns out to be something very simple: When reordering the blocks of code in the .module file I managed to remove hook_giftwrap_commerce_line_item_type_info(). That's reinstated now so you shouldn't have any issues.
Once again, thanks for the reviews @tinker and @iler.
Comment #10
msmithcti commentedComment #11
tinker commentedHi Splatio, checked out the latest version and the gift wrap message went through without error. There is however another issue to do with the gift wrap price. I was lazy and entered "10". When the checkout completed I noticed that the order charged 10 cents ".10" rather than 10 dollars. This is probably because the addition was expecting a decimal number. I do not know the proper way of doing this but I am pretty sure that commerce will have some form validation functions for currency. You should implement those on the gift wrap settings form.
You should filter_xss($message,array()) the commerce_giftwrap_message text provided by the user on the checkout form to strip out HTML and make sure its safe to use.
Oh and BTW since you are using Netbeans have a look at the following to aid setup to auto follow drupal coding standards:
http://drupal.org/node/1019816
http://drupal.org/project/nb_templates (great for hook templates)
Then you can Source -> Format and it will remove most formatting errors.
Comment #12
msmithcti commented@tinker - The price handling was something I skimmed over when fleshing out the module but ended up forgetting about improving! As far as I'm aware prices should be stored as the 'minor' value, so, 200 = 2.00 USD. Commerce offers the functions
commerce_currency_amount_to_decimal()andcommerce_currency_decimal_to_amountto switch between these. Since there is no 'base_settings_form_submit()' I've had to add it myself by altering the 'parent' form so I can convert the decimal value input to the minor value to be stored in the database.A bit of a schoolboy error not filtering the users input. I've made the decision to use check_plain() instead of filter_xss() as the message will be physically printed out/hand written so plain text would make more sense.
I had set Netbeans up using both the resources you posted however I guess it doesn't necessarily stop errors sneaking through!
Source -> Format is new to me and I'll definitely be making use of it.
Comment #13
tinker commentedHi @splatio,
Sorry for not being clear about user input validation. This should take place before the input is stored and not just when it is being displayed. This way you always know that processed user input is safe. Since you have a textfiled input without an online editor I am assuming that users should enter plain text and you do not want users to enter any HTML code. check_plain($message) encodes HTML characters so they will not affect output format. So if user inputs
<b>Bold text</b>it will not be displayed as bold but will be stored encoded and displayed exactly as input showing the code<b>Bold text</b>in the message. filter_xss($message,array()) strips out all HTML code so if user inputs<b>Bold text</b>it will be stored and displayed as "Bold Text". What you are worried about is<iframe>tags that could hijack the site but I assumed you did not want any HTML tags.So to ensure safe input without any HTML code it should be in commerce_giftwrap_pane_checkout_form_submit() where you set:
If you want to allow certain HTML tags such as bold, italic etc then set array() to contain the allowed tags. e.g. array('b','i') or just exclude array() from the function to use defaults. But since you have a plain textarea input I am assuming you do not want any HTML.
I will check out commerce_giftwrap_pane_settings_form_submit(). I thought this was automatic. If not then your original code of adding
$form['#submit'][] = 'commerce_giftwrap_pane_settings_form_submit'in commerce_giftwrap_pane_settings_form() was better then the hook_form_commerce_checkout_pane_settings_form_alter().Comment #14
msmithcti commented@tinker - Thanks for the time and effort you're putting into this review!
I had understood the differences between filter_xss() and check_plain() however for some reason it hadn't clicked properly when thinking about it in this instance. It certainly makes more sense filtering once on input! Thanks for the really good explanation of this.
I completely agree that
commerce_giftwrap_pane_settings_form_submit()>$form['#submit'][] = 'commerce_giftwrap_pane_settings_form_submit'>hook_form_commerce_checkout_pane_settings_form_alter()but it was the only one that worked!Comment #15
ionut.alexuc commentedHi splatio,
I found some minor issues with your module.
I'm using the latest commerce_kickstart (http://drupal.org/project/commerce_kickstart).
1. When I use a custom message for Gift Wrapping, I can see it on "Review Order" page. That's fine.
If I click "Go back" to change something on my order, then my custom message is not displayed.
You don't set the #default_value in case there is an existing message available.
2. You can't change your custom message once added!
Let's say you saw on "Review Order" that your custom message is wrong. If you go back and edit the message, when you click Next the new message is not saved.
You could update the Message on _submit if there is an existing GiftWrapping in the line items. Right now, you just skip it.
Everything else looks nice to me.
Comment #16
iler commentedUpdating the status to needs work.
Comment #17
msmithcti commentedThanks for spotting those issues @ionut.alexuc, they should all be sorted in the latest commit.
Comment #18
ionut.alexuc commentedHi,
I've reviewed your latest changes. You have fixed the issues from #15.
I have another issue with
If there is no line item for gift wrapping, the $message is not set.
I get:
You get that warning on "review" page when you don't want a gift wrapping.
Comment #19
msmithcti commentedAh, my bad - should have spotted that when testing! That's now sorted.
Comment #20
ionut.alexuc commentedHi,
Another two issues found.
1. Just disable the module and then enable it again.
2. I've uninstalled the module and the variables are still in database. For example this one:
You have to use hook_unisntall and delete them.
Comment #21
msmithcti commentedHi,
That should all now be sorted. I've created a .install file with a hook_install() to remove the variables that have been set and to delete the giftwrap message field and instances of it. I'm also now checking if the field is already there or not which should prevent the error message you were getting.
Comment #22
msmithcti commentedComment #23
ionut.alexuc commentedHi
Use the following workflow:
- Enable the module and create one order with a Gift Wrap
- Add products to cart, add gift wrap, go to review page. You will see the Gift Wrap in review.
- Uninstall the commerce_giftwrap module.
- On review page, you will see it the gift wrap with empty label, but the price is still there.
- Go back to cart page, when you click submit you get:
- Try to edit the order that already contains the GiftWrap. You will get another error.
I don't think it is ok to delete the line item type: giftwrap.
I think that is causing the issues because order wrapper is trying to load it.
Comment #24
msmithcti commentedHi,
Apologies for the late reply. I've been unable to recreate the errors you got both in a previous install and a brand new installation of Commerce Kickstart + Giftwrap. Here's the workflow I used:
I didn't come across any errors throughout that process, have I missed something?
When writing this module I've taken many cues from the shipping module, so I tried the above workflow with commerce_shipping 7.x-2.x. I noticed that I was getting the same empty label with just a price. On one hand, as far as I understand uninstalling a module should remove all traces of it, but is it right to alter all the orders within the site by removing the giftwrapping? Probably not.
Comment #25
msmithcti commentedComment #26
sreynen commentedIt looks like this should actually be "needs review" status, since it's the applicant, not the reviewer, who needs more info. In the review queue, the reviewers are the "maintainer," so they won't often look at something marked "maintainer needs more info."
Comment #27
misc commentedManual review:
commerce_giftwrap.installandcommerce_giftwrap.moduleyou are missing a finishing new line in the end of the fileif (), notif().Else, this look RTBC for me.
Comment #28
msmithcti commentedThanks for reviewing MiSc, those issues should now be sorted.
Comment #29
klausiSorry for the delay, but you have not listed any reviews of other project applications in your issue summary as strongly recommended in the application documentation.
Review of the 7.x-1.x branch:
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. Get a review bonus and we will come back to your application sooner.
manual review:
Otherwise the code looks good, but security issues are application blockers, so I need to bump this back to "needs work".
Comment #30
msmithcti commentedHi klausi,
Thanks for your time reviewing this, those issues should all be sorted in the latest commit.
I've also started reviewing some other projects.
Comment #30.0
msmithcti commentedchanging git information from link to code
Comment #31
misc commentedTook a look, anfd this seems like RTBC for me.
Comment #32
klausimanual review:
"
'#markup' => '<h3>Giftwrap Message</h3>',": all user facing text should run through t() for translation.But that is just a minor issue, so ...
Thanks for your contribution, splatio! Welcome to the community of project contributors on drupal.org.
I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.
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.
As you continue to work on your module, keep in mind: Commit messages - providing history and credit and Release naming conventions.
Thanks to the dedicated reviewer(s) as well.
Comment #33.0
(not verified) commentedAdding reviews of other projects.
Comment #34
Yakiv Shumenko commentedHello klausi
I have a doubt about giftwrap message.
I am working on the www.uppermen.com.br now.
I have written the giftwrap message and click the checkout.
But the store owner doesn't have access to the gift message.
It's very kind of you to help me about this issue.
Regards Yakiv
Comment #35
tinker commented@Yakiv Shumenko. The commerce_giftwrap project has already been approved and published. If you have a problem with the module then report it in the issue queue for the project: https://www.drupal.org/project/issues/commerce_giftwrap
Project main page is : https://www.drupal.org/project/commerce_giftwrap
This issue queue is for project application before it is published.