I create a shippable product and set price to 'abc' instead of 23.12,
and save ,it show no error.
then I closer to this issue,I found when product node is create , function product_form_validate is not called .

CommentFileSizeAuthor
#4 55066.patch578 bytesneclimdul

Comments

oscnet’s picture

Version: 4.6.x-1.x-dev » master

I test with cvs version.

oscnet’s picture

product.module:733
<?php
function product_validate(&$node) {
  if(strstr($_GET['q'], "node/$node->nid/edit")) {    // why check it ?
    product_form_validate($node);
  }
}
?>
sime’s picture

This is critical. It might be ok for other products, but auction.module requires validation to convert the expiry date string to a timestamp. So expiry is set to epoch.

neclimdul’s picture

StatusFileSize
new578 bytes

I tend to agree, we always want to call the validate hook. Attached is a patch that removes this. Alternatively, if we wanted to leave the check in (for whatever reason) we would change the check to if (strpos($_GET['q'], "node/$node->nid/edit") !== false). Its cheaper and will work as intended.

This doesn't fix Simon's problem however. Product.module uses the _validate, _insert, and _update hooks for triggering the productapi. This is fine except the node's state doesn't seem to be kept between hooks. So after this patch his modifications in validate are still lost. This might be considered a "feature" in core but it causes a problem here. We might look at modifying the product api to fix this or just document that that is the nature of the productapi as I'm pretty sure we aren't going to get any changes into 4.7 core now. *smile*

gordon’s picture

Status: Active » Fixed

Commited to cvs.

Anonymous’s picture

Status: Fixed » Closed (fixed)