uc_product_adjustments table, serialize key not set in schema, causing problems with drupal_write_record

irarab - November 2, 2009 - 17:55
Project:Ubercart
Version:6.x-2.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

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
      ),

 
 

Drupal is a registered trademark of Dries Buytaert.