After installing the new release 6.x-1.x-dev, running update.php didn't change the db scheme from previous version. Adding/listing/editing previously existing embed_widget throws error:

user warning: Unknown column 'sources' in 'field list' query: INSERT INTO txtdomain_embed_widgets (title, description, sources, footer, standalone) VALUES ('test', 'test', 'a:1:{i:0;a:3:{s:4:\"type\";s:4:\"page\";s:4:\"path\";s:6:\"node/1\";s:5:\"title\";s:10:\"Test Page \";}}', 'test', '0') in H:\xampp\htdocs\drupal62\sites\all\modules\embed_widgets\embed_widgets.module on line 188.

Inspection of code suggest missing update hook for drupal_load_updates.

See following for reference:
http://api.drupal.org/api/function/drupal_load_updates/6/references
http://blamcast.net/articles/update-module-install-database-schema

Comments

jtsnow’s picture

I added the following code to the install file. It should provide an updated schema.


/**
 * Implementation of hook_update_N().
 */
function embed_widgets_update_6001() {
  $ret = array();
  db_add_field($ret, 'embed_widgets', 'sources', array('type' => 'text', 'size' => 'medium', 'not null' => TRUE, 'default' => '', 'description' => t('An array of sources used by the widget.')));
  db_add_field($ret, 'embed_widgets', 'standalone', array('type' => 'int', 'length' => '1', 'not null' => TRUE, 'unsigned' => TRUE, 'default' => '0', 'description' => t('0 if can have multiple soures, 1 if corresponds to one source.')));
  
  $result = db_query("SELECT * FROM {embed_widgets} WHERE 1");
  if ($result) {
    while ($embed_widget = db_fetch_array($result)) {
      if ($embed_widget['type'] == 'block') {
        $embed_widget['sources'] = array(
          '0' => array(
            'type' => 'block',
            'module' => $embed_widget['arg1'],
            'delta' => $embed_widget['arg2'],
            'title' => $embed_widget['title'],
            )
        );
      }
      else if ($embed_widget['type'] == 'page') {
        $embed_widget['sources'] = array(
          '0' => array(
            'type' => 'page',
            'path' => $embed_widget['path'],
            'title' => $embed_widget['title'],
          )
        );
      }
      embed_widgets_save($embed_widget);
    }
  }
  db_drop_field($ret, 'embed_widgets', 'path');
  db_drop_field($ret, 'embed_widgets', 'arg1');
  db_drop_field($ret, 'embed_widgets', 'arg2');
  db_drop_field($ret, 'embed_widgets', 'type');
  return $ret;
}

rpfilomeno’s picture

Worked like a charm.

nedjo’s picture

Status: Active » Fixed

Great.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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