Closed (fixed)
Project:
Ubercart Out of stock Notification
Version:
6.x-1.4
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
4 Mar 2010 at 11:34 UTC
Updated:
8 Oct 2011 at 22:31 UTC
Jump to comment: Most recent file
Comments
Comment #1
fabio84I have spoken too early...
If in the page there are more than one "add to cart" form, Drupal.settings.uc_out_of_stock.query_path is setted more than once, and it becomes an array (an effect of array_merge_recursive() used to glue the parts in Drupal.settings), making the throbbler spin forever.
So I defined a static variable in order to set this variable (and add javascript/css) only once.
Now it works better for me.
Comment #2
hanoiiQuick review/comments, haven't tested.
* The use of i18n_variables in the init is something standard. I am aware that this should be set on the settings.php file, although I can't think why it cannot be set on the init().
* Is your patch standard unified format? It looks odd from what I am used to see (not sure what the ! stands for in the diff format).
Static var is probably not needed, I guess you can add the setting on the init() hook as well, and leave the addition of the css and js where they are now, that w/o the static var.
Comment #3
hanoiiComment #4
fabio84I found out that also in the "core" ubercart modules multilingual variables are defined in hook_init in this way.
I used Eclipse to edit the source and generate the patch. I chose the format "context", but probably I had to chose "unified", sorry... this should be better.
Comment #5
hanoiican you please not use the static variable and try what I mentioned on #2?
Comment #6
fabio84I had to add the static variable in the second patch because in catalog pages uc_out_of_stock_form_alter is called more than once, so it ensures that Drupal.settings.uc_out_of_stock.query_path is defined only once (otherwise it becomes an array, as I said in #1).
So while I fixed this, I ensured also that the javascript and the css are requested only once. (it doesn't cause problems, but it may improve performance of milliseconds... I'm obsessed with this kind of useless optimizations)
I think is better to define this value only before the inclusion of the javascript, because it's useless if the javascript is not included.
Anyway, this patch is working for me and I'm already using it on a live site, and I'm happy with it.
Comment #7
hanoiiI appreciate your help with this and this will probably be committed soon. I was asking you to rework that bit only because I feel it's better and cleaner. A setting in the Drupal JS object, even if it's not used, won't really bother at all and I rather use static variables to control one-time execution code only if really necessary as, in my personal opinion, not having it adds readability.
It's not a big deal anyway and It's fine that you are happy with it. I was just mentioning this small tweak only if you were interested in doing it so it can goes directly into the code.
I'll review it soon and fix it.
Thanks again,
a.=
Comment #8
blecheimer commentedthanks for the patch - it is working for me...that is what I needed ;-)
Comment #9
Romejoe commentedComment #10
hanoiiHad to re-roll it to cope with recent changes,,but thanks!