I found a bug in the uc_attribute module for UC-2 Drupal 6.
The Schema for the table uc_product_adjustments has a field combination, which is described as A serialized array whose keys are attribute IDs and values are option IDs.
In order for drupal_write_record to work the schema must be set to serialize for a field holding a serialized array. Drupal Schema API specifies a key 'serialize': A boolean indicating whether the field will be stored as a serialized string
The key is not set for the uc_product_adjustments table. This causes problems when saving a record using drupal_write_record if you pass in an array for the combination field.
SOLUTION:
File: uc_attbibute.install
Around line 355. Add 'serialize' => TRUE to the definition for 'combination'
So it reads
'combination' => array(
'description' => t('A serialized array whose keys are attribute IDs and values are option IDs.'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'serialize' => TRUE // added this line
),
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 621210-attribute-schema-serialize.patch | 487 bytes | longwave |
Comments
Comment #1
selinav commentedhow to do this in my base when the module is ever installed?
Comment #2
Ira Rabinowitz commentedI don't understand?
Comment #3
tr commentedReclassifying as a feature request because the module works as-is - Ubercart doesn't use drupal_write_record() for this table. But this sounds like a change we should make going forward. Can you put your fix into patch form, and also change the existing queries on that table to use drupal_write_record()?.
Comment #4
longwaveLet's see what testbot thinks of this.
Comment #5
longwaveCommitted to 7.x. Not sure we should change this now in 6.x, just in case there's existing code relying on the old behaviour and serializing things before calling drupal_write_record().