Closed (fixed)
Project:
e-Commerce
Version:
5.x-4.x-dev
Component:
product
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Mar 2007 at 20:13 UTC
Updated:
11 May 2007 at 12:24 UTC
If is enabled module 'Product API' then the administrator won't see preview for any node type. If the module is disabled then everything works fine again.
I'm able to obtain this bug repeatedly:
1] install DRUPAL 5.1 on Windows with Apache 2.0.59, MySQL 5.0.27, PHP 5.1.6
2] enable token.modulle (till this point everything works fine)
3] enable 'Product API' and admin cannot see preview after clicking Preview button, other users can
4] disable 'Product API' and Preview button works again
Comments
Comment #1
courtney commentedI'm having the same problem. When the product API module is enabled and I try to preview any type of content on my site, it returns the edit form without the preview of the post.
I'm running ecommerce-5.x-3.x-dev downloaded on 3/19/07.
thx!
Comment #2
mercmobily commentedI can confirm this bug. It's not a tragedy, but it is rather annoying.
I looked into the code, and couldn't figure out why on earth this would happen...
The problem is obviously in:
function product_form_alter($form_id, &$form)
This causes the issue:
if (user_access('administer products') && $form['type']['#value'] != 'product') {
[...]
#$form['#after_build'] = array('_product_transform_skip_validation');
}
Now, the problem is somewhere in _product_transform_skip_validation
The code is:
function _product_transform_skip_validation($form, $edit) {
if ($_POST['op'] == t('Add to store')) {
_product_skip_validation($form);
}
return $form;
}
I am not at all familiar with the after_build mechanism. However, reading the documentation:
http://api.drupal.org/api/5/file/developer/topics/forms_api_reference.ht...
It looks like the variable $edit should be returned, rather than $form. I tried that, and well, it didn't work at all. Besides, it's the $form that needs to be changed...
I am out of ideas. However, this report should at least point a person with real Drupal skills to fix it properly. Till then, the person who administers the products can't see the preview - AND, I am not sure this is just the effect of a much worse bug in the code.
I will keep an eye on it - please have a look!
Merc,
The
Comment #3
mercmobily commentedHi,
I looked into it more, and I was full of it - it is indeed "form" that needs to be returned...
God knows why "system" doesn't. Oh well!
Anyhow, I found the problem!!!
the node.module has:
$form['#after_build'] = array('node_form_add_preview');
Now, if the ecommerce module does this:
$form['#after_build'] = array('_product_transform_skip_validation');
It effectively KILLS the node's preview after_build function!
So, that line needs to be:
$form['#after_build'][] = array('node_form_add_preview');
And the problem is solved. I think this is "the" solution to the problem - please check and make the change. I won't include it as a patch as ALL there is is a missing set of square brackets [] (line 443).
Bye!
Merc.
Comment #4
gordon commentedThis has been fixed in v3-dev and v4-dev
Comment #5
killes@www.drop.org commented