2
votes

I needed to change the data_scale of a decimal field implemented by the module "computed field". I changed the field_data_MYFIELD directly in database (from 10,2 to 10,4). I also modified the field_revision_MYFIELD the same way. As third step, I modified the data of the field_config by changing:

FROM

s:14:"data_precision";s:2:"10";s:10:"data_scale";s:1:"2";

TO

s:14:"data_precision";s:2:"10";s:10:"data_scale";s:1:"4";

As I'm trying to clear caches with drush cc all, I get the following error:

PHP Fatal error: Unsupported operand types in DRUPAL_SITE/modules/field/field.info.class.inc on line 495

The line 495 is:

// Make sure all expected field settings are present.
$field['settings'] += field_info_field_settings($field['type']);

I enabled the error log in index.php and have the following errors:

  • unserialize(): Error at offset 330 of 1314 bytes in DRUPAL_SITE/modules/field/field.crud.inc on line 374
  • Notice: Undefined index: settings in DRUPAL_SITE/sites/all/modules/computed_field/computed_field.install on line 13
  • Undefined index: settings in DRUPAL_SITE/modules/field/field.info.class.inc on line 495
  • Fatal error: Unsupported operand types in DRUPAL_SITE/modules/field/field.info.class.inc on line 495

What am I doing wrong?

3

3 Answers

0
votes

Never a good idea to alter settings via mysql directly, take a look here to do it from code : https://drupal.stackexchange.com/questions/79378/changing-a-field-type-from-integer-to-decimal/151367#151367

0
votes

Instead, you could have use an hook_update to alter the field.

0
votes

Thank you Clive. I did'nt paste the whole data ...apologize. The data_precision etc keys are indeed inside a database key within that string. I tested the data content into http://blog.tanist.co.uk/files/unserialize/ (as suggested) and the string is not valid ... you were right. I fixed it by changing different values of the S lenght in order to match the content of each S . After some tests, the problem is now resolved. It appears that editing the Blob data (for computed fields with php code inside) directly from phpmyadmin is not a good idea as far as it adds many additional char that doesn't match the lenght of the S. Thanks again for your help.