After upgrading from 2.1 to 2.2 I started encountering this error when trying to edit a node:

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'weight' at row 1: UPDATE {weight_weights} SET weight=:db_update_placeholder_0 WHERE ( (entity_id = :db_condition_placeholder_0) ); Array ( [:db_update_placeholder_0] => [:db_condition_placeholder_0] => 58 ) in _weight_set_weight() (line 544 of C:\inetpub\wwwroot\sites\all\modules\weight\weight.module).

The site was originally upgraded from Drupal 6 which also used the Weight module. However the error just started appearing after the recent upgrade from 2.1 to 2.2. I had to disable the module to allow node edits. Please let me know if I can provide any other useful information. Is it possible to downgrade to 2.1 with out any ill effects?

CommentFileSizeAuthor
#11 1922808-11.patch680 bytesvalthebald
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

toshubuntu’s picture

Same problem for me after upgrading to 2.2. I can't modify any previous node without having that same identical message:

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'weight' at row 1: UPDATE {weight_weights} SET weight=:db_update_placeholder_0 WHERE ( (entity_id = :db_condition_placeholder_0) ); Array ( [:db_update_placeholder_0] => [:db_condition_placeholder_0] => 53 ) in _weight_set_weight() (linea 544 di /srv/data/web/vhosts/*******/htdocs/sites/all/modules/weight/weight.module).

I have a unique content type using Weight for all nodes created.
I deactivated Weight at the moment because my site is till in dev.

Drupal 7.20 | Firefox 19.0 | MYSQL 5.5.28-1-log - (Debian)

vegancheesesteak’s picture

Priority: Normal » Major

My issue is on a live site. I've had to disable Weight for now so we can make content revisions.

Is it safe to downgrade to 2.1?

nessunluogo’s picture

I had this problem too in a fresh installation.
Turning off the "Use Menu Weight" fixed my problem.

Hope this helps.

davisben’s picture

Status: Active » Fixed

This is occurring when menu weight is enabled, but the node being saved doesn't have a menu link. I added a check to set the weight to the default if there is no menu link.

Status: Fixed » Closed (fixed)

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

ellolo’s picture

I just encountered this exception with version 7.x-2.2 when trying to unpublish a node or setting a different weight:

PDOException : SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'weight' at row 1: UPDATE {weight_weights} SET weight=:db_update_placeholder_0 WHERE ( (entity_id = :db_condition_placeholder_0) ); Array ( [:db_update_placeholder_0] => [:db_condition_placeholder_0] => 35 ) dans _weight_set_weight() (ligne 551 dans /home/tata/drupal7/sites/all/modules/weight/weight.module).

I modified a few lines in the file "weight.module" to make it work, though I am not sure that I correctly handle "menu_links". In the function _weight_set_weight($node), around line 520, I wrote this:

function _weight_set_weight($node) {
  // Default weight value: passed in weight value                                                     
  $weight = $node->weight_weight;

  // Get the settings for this node                                                                   
  $settings = _weight_get_settings($node->type);

  // If menu_weight selected & exists, override menu weight                                           
  if ($settings['menu_weight']) {
    // Get the menu weight for this node (if it exists).                                              
    $weight_query = db_select('menu_links', 'ml');
    $weight_query->fields('ml', array('weight'))
      ->condition('link_path', 'node/' . $node->nid);
    $ml_weight = $weight_query->execute()->fetchField();
    if ($ml_weight !== FALSE) {
      $weight = $ml_weight;
    }
  }
  ...
  db_merge('weight_weights')
  ...
}

The modification involves:
1/ some replacements of the variable '$weight' with '$weight_query' to avoid mixing of different meanings for a same variable and avoid that '$weight' contains a query instead of an integer
2/ a test of what the query found. On my website, it is possible that no record was returned so FALSE is obtained.

With these modifications, db_merge() does not fail anymore.

Nicolas Bouteille’s picture

Status: Closed (fixed) » Active

The bug also happens when the translation sync is enabled even if the menu weight is disabled.

davisben’s picture

Status: Active » Closed (fixed)

The fix for this was committed after 7.x-2.2 was released, so it isn't in that version. Using 7.x-2.x-dev will fix this, or you can wait for 7.x-2.3, which will be out in a week or two.

phoenix’s picture

Status: Closed (fixed) » Active

I have a Drupal site with the weight module. I had the same PDO exception. Now installed 7.x-2.x dev snapshot and I still have this problem.

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'weight' at row 1: INSERT INTO {weight_weights} (entity_id, entity_type, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 486 [:db_insert_placeholder_1] => node [:db_insert_placeholder_2] => ) in _weight_set_weight() (line 592 of ......../contrib/weight/weight.module).

phoenix’s picture

I checked the code. I created a new translation, translated the node, push submit and get the error. When checking line 592, I see a merge query and apparently it doesn't have a weight.

Just before this query I see this:
_weight_get_weight($node->tnid);

When checking the _weight_get_weight function, it will try to retrieve the weight via a query, but this node doesn't exist yet...

$weight = db_query("SELECT weight FROM {weight_weights} WHERE entity_id=:id AND entity_type=:type",
    array(':id' => $nid, ':type' => 'node'))->fetchField();

So nothing is returend. I added this piece of code after this query:

if (empty($weight))
    $weight = 0;

I know it is not fully correct, as the weight will always be 0 when a new translated node is submitted.
Maybe we can try to get the weight from the node object. But I don't know which property that is.

valthebald’s picture

Version: 7.x-2.2 » 7.x-2.x-dev
Status: Active » Needs review
FileSize
680 bytes

It may happen that variable_get() returns boolean FALSE (which caused this error in my install)
Attached patch makes explicit cast in weight_update_7200()

13rac1’s picture

Status: Needs review » Reviewed & tested by the community

Works and applies to latest dev.

davisben’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the patch!

Status: Fixed » Closed (fixed)

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

MastaP’s picture

Was this issue ever fixed into a recent update?

I am getting

PDOException : SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'weight' at row 1: UPDATE {weight_weights} SET weight=:db_update_placeholder_0 WHERE ( (entity_id = :db_condition_placeholder_0) ); Array ( [:db_update_placeholder_0] => [:db_condition_placeholder_0] => 267 ) dans _weight_set_weight() (ligne 544 dans /var/www/sites/all/modules/weight/weight.module).

thanks.

bessone’s picture

Issue summary: View changes

I have the same problem changing the node's weight in a View with Weight 7.x-2.3

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'weight' at row 1: INSERT INTO {weight_weights} (entity_id, entity_type, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 271 [:db_insert_placeholder_1] => node [:db_insert_placeholder_2] => ) in _weight_set_weight() (linea 592 di /var/www/xxx/sites/all/modules/weight/weight.module).