If the price amount is left empty on Product Variation inline entity form, then the site will become WSOD.

CommentFileSizeAuthor
#6 2671050-4.patch489 bytesskyredwang
#3 2671050-3.patch605 bytesskyredwang
#2 2671050-2.patch609 bytesskyredwang
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

skyredwang created an issue. See original summary.

skyredwang’s picture

Status: Active » Needs review
FileSize
609 bytes

Patch is attached

skyredwang’s picture

FileSize
605 bytes

Clear the spacing in the previous patch

bojanz’s picture

Status: Needs review » Needs work

What's the actual error that's reported?

skyredwang’s picture

The actual error is:

Uncaught PHP Exception Drupal\\Core\\Entity\\EntityStorageException: "SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect decimal value: '' for column 'price__amount' at row 1: INSERT INTO {commerce_product_variation_field_data} (variation_id, type, langcode, uid, product_id, sku, title, price__amount, price__currency_code, status, created, changed, default_langcode) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12); Array\n(\n [:db_insert_placeholder_0] => 15\n [:db_insert_placeholder_1] => default\n [:db_insert_placeholder_2] => en\n [:db_insert_placeholder_3] => 1\n [:db_insert_placeholder_4] => 5\n [:db_insert_placeholder_5] => 45\n [:db_insert_placeholder_6] => Product 1\n [:db_insert_placeholder_7] => \n [:db_insert_placeholder_8] => CNY\n [:db_insert_placeholder_9] => 1\n [:db_insert_placeholder_10] => 1457593015\n [:db_insert_placeholder_11] => 1457593121\n [:db_insert_placeholder_12] => 1\n)\n" at /var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php line 757,

skyredwang’s picture

Status: Needs work » Needs review
FileSize
489 bytes

@bojanz on IRC suggested that we need to fix the problem at field level, so it won't happen to any instance of price field.

Patch attached.

mglaman’s picture

  • bojanz committed 579ef82 on 8.x-2.x authored by skyredwang
    Issue #2684713 by skyredwang: WSOD if price amount is NULL
    
bojanz’s picture

Status: Needs review » Fixed

Went with:

  return $this->amount === NULL || $this->amount === '' || empty($this->currency_code);

Cause that means "0 USD" is an actual non-empty value, which I believe is more correct.

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.