After updating to 6.x-2.10-rc3 I can no longer attach files to nodes. When I try I get the message referenced:

“Query Failed: Could not attach files to node 1282”

It doesn't matter what the node number happens to be.

Also I note that when running htpp://www.example.com/update.php if I expand the "select versions" box and look, there is NO webfm drop down available.
Runing Drupal 6.6.

Comments

tcblack’s picture

I'm finding this in my logs when I try an attachment with webfm. I'm fairly certain it's related to not having an update available to update.php

Unknown column 'cid' in 'field list' query: INSERT INTO webfm_attach (nid, fid, weight, cid) VALUES (1367, 1592, 1, 0) in /home/stilbla0/public_html/sites/all/modules/webfm/webfm.module on line 3086.

robmilne’s picture

Status: Active » Closed (works as designed)

I made it clear in the release note that a db update was required. The following is in webfm.install...

/**
 * Add column for comment id in webfm_attach table.
 */
function webfm_update_1() {
  $ret = array();
  // Add the new column to store a comment id.
  db_add_field($ret, 'webfm_attach', 'cid', array('type' => 'int', 'not null' => TRUE, 'default' => '0'));

  // Make it a primary key.
  db_drop_primary_key($ret, 'webfm_attach');
  db_add_primary_key($ret, 'webfm_attach', array('nid', 'cid', 'fid'));
  return $ret;
}

Simply go to http://your/drupal/site/update.php. Please close this issue if this resolves the problem.

gandhiano’s picture

I also have problems with uploading files, even after manually selecting version 1 in update.php.

This happened after a migration from drupal 5.x (can't remember the webfm module version).

The error I get whenever I update a file is:
user warning: Unknown column 'perm' in 'field list' query: INSERT INTO webfm_file (fpath, uid, fsize, fcreatedate, perm, fmime) VALUES ('path/to/webfmfiles/file.pdf', 1663, 100408, 1231352103, 0, 'application/pdf') in /etc/drupal/6/sites/all/modules/webfm/webfm.module on line 2663.

And I get the following error after running the update:
user warning: Duplicate column name 'cid' query: ALTER TABLE webfm_attach ADD `cid` INT NOT NULL DEFAULT '0' in /usr/share/drupal6/includes/database.mysql-common.inc on line 298.

The following queries were executed
webfm module
Update #1
Failed: ALTER TABLE {webfm_attach} ADD `cid` INT NOT NULL DEFAULT '0'
ALTER TABLE {webfm_attach} DROP PRIMARY KEY
ALTER TABLE {webfm_attach} ADD PRIMARY KEY (nid, cid, fid)

robmilne’s picture

Yikes! If the perm column is unknown it means you were using a pre 5.x-2.3 version of the module which predates file permissions (released Jan3 08). You cannot migrate a pre 5.x-2.7 version of webfm to a 6.x version without first upgrading to a post 5.x-2.7 version of the module. I'm sorry that this proviso was never clearly stated anywhere but this is the first instance of this issue I've seen. My advice (assuming you have a backup of the db) is to upgrade your pre 5.x-2.7 version of the module to a later 5.x version and then migrate the db to 6.x.

I will make a note of this on the project page.

dinis’s picture

Hmm, I get exactly the same issue as gandhiano but after upgrading from 5.x-2.15 (though this itself has been through a number of updates.

I'm about to try a fresh install and see how that turns out.

Andrzej7’s picture

I have updated it manually and it helped.

Thanks for the tip.

tcblack’s picture

Unfortunately Webfm doesn't even show up on the udpate.php page. And I have steadfastly upgraded every single version number in order. Somewhere along the line between rc2 and rc4 it quit working.

And yes I did do rc3 but had to downgrade because it started dropping attachments.

Ah, the light just came on. Downgrading from rc3 to rc2 and then jumping to rc4 must have caused the problem.
Mea Culpa.

The good news is that after adding the cid to the webfm_update table (int, not null, default=0, as primary key) It appears to be working great.

Thanks for the pointer to the cure!

tcblack’s picture

Status: Closed (works as designed) » Fixed
tcblack’s picture

Status: Fixed » Closed (fixed)

Closed per Comment 2

strellman’s picture

Oops. I also upgraded from d5 to d6 and forgot to update webfm as far as possible on d5 first. Thank you for pointing me to webfm.install. I was able to find these updates to the database and do them manually with phpmyadmin after the fact. (Well it sure beats uninstalling and recreating all of our webfm data.)

ALTER TABLE webfm_file ADD perm tinyint NOT NULL DEFAULT 0
ALTER TABLE webfm_file ADD dl_cnt int NOT NULL DEFAULT 0
ALTER TABLE webfm_attach DROP list

ALTER TABLE webfm_file DROP fname