Bug #22872 Bug Fixed

Changing from Date field to a different compatible field triggers error and data loss

Version: 3.4.7 Reporter: Derek Hogue

I have an add-on (Event Helper) which is declared compatible with Date fields in the add-on setup file. I was just alerted via a support request that when changing an existing Date field to an Event Helper field, it triggers an error. I just confirmed locally.

Unknown column 'field_id_10' in 'exp_channel_data':
ALTER TABLE `exp_channel_data` CHANGE `field_id_10` `field_id_10` INT(10)

It appears that rather than the diff method running to properly drop only what’s needed and change existing cols, th field is being dropped entriely, and thus can’t be updated.

If I first create and Event Helper field, then convert it to a Date field, it converts properly.

I do have a settings_modify_column method:

function settings_modify_column($data)
    $fields['field_id_'.$data['field_id']] = array(
     'type' => 'INT',
     'constraint' => 10
    return $fields;

But even if I remove that method, the same error is triggered (the error indicates that EE is trying to change the field to ‘text’ in that case).

I can send a copy of the add-on if you like.

  • D’oh you’re right, sorry about that. Easy fix though. If you want to try it out, open system/ee/EllisLab/ExpressionEngine/Model/Content/FieldModel.php and find this code on line 318:

    $columns = $this->ensureDefaultColumns($columns);

    And DELETE it.

    Kevin Cupp
    09th January, 2017 at 4:04pm
  • Worked! Thanks.

    Derek Hogue
    09th January, 2017 at 4:25pm

You must be signed in to comment on a bug report.

ExpressionEngine News

#eecms, #events, #releases