Problem/Motivation
When adding a File Download Product Feature, the Product Feature ID (pfid) is not available in the beginning of the process (as expected). The 'pfid' gets created by uc_product_feature_save()
during the execution of uc_file_feature_form_submit()
.
The issue is that there is an index in the $form_state
called $form_state['values']['pfid']
which is expected to store the 'pfid' but is NULL even after we get the 'pfid' from uc_product_feature_save()
.
This makes it hard for other modules to rely on the $form_state
data whenever altering this form and adding another submit handler because the 'pfid' would only be available in the $form_state
whenever the user goes back and edit the Product Feature.
Proposed resolution
The solution is to set the 'pfid' on the $form_state
as soon as it is made available by uc_product_feature_save()
.
Comment | File | Size | Author |
---|---|---|---|
#2 | ubercart-missing-pfid-2909260-2-D7.patch | 555 bytes | dscl |
|
Comments
Comment #2
dscl CreditAttribution: dscl at DevBrains commentedComment #3
TR CreditAttribution: TR commentedComment #4
Morbus IffSeems like a bug to me, as it affects other code in
uc_file_feature_form_submit()
:If this is a new file being created, then PFID is empty here:
which causes it to remain empty here:
Then, we create the feature, which sets the pfid into $data via reference:
but this newly-generated pfid is never saved back into $file_product, which is then checked later:
Comment #5
TR CreditAttribution: TR commentedSo please clarify, what doesn't currently work?
I will be glad to add something to improve extensibility (feature), but a bug means something isn't currently working properly...
Comment #7
TR CreditAttribution: TR commentedThanks. I committed the patch.
Comment #8
TR CreditAttribution: TR commentedActually, need to put this in D8 too ...
Comment #10
TR CreditAttribution: TR commentedI made a very similar change to uc_roles.module, since that is the other product feature module in Ubercart, and it shares much of the same code structure.
Both uc_file and uc_role need this patch in D8 now.