Hi,

I use weight to get the items in our store in the correct order. When updating from 7.x-1.0 to 7.x-2.0-beta3 I had to update the weight changer view an add the sorting by the new weight fields to all the views where I used it.

The product listing view lists nodes with product information received from the product entity from a relationship, as well as a relationship on taxonomy terms.

After playing around with my old view I where I got the duplicates as soon as I added weight as sorting criteria I

  1. cloned the default weight sorting view
  2. added a filter for the Node type that links to the products
  3. set the pager to display all items (which are in my case between 80 and 100)
  4. duplicates for all of the node titles are shown so I set Distinct in the Query Settings
    Now some but not all of the duplicates are gone.

The duplicated entries are not necessary the ones referencing multiple products.

Maybe it is also important, that I had weight enabled for the product node type before updating. The product node type has, beside the weight field, just title, body, product_reference and one reference on taxonomy term field.

I also tried to add weight-ability with 7.x-2.0-beta3 to another node type with a user reference field and have been able to sort and list the nodes as desired.

Therefore I think it is either a problem upgrading from the 1.0 to 2.0-beta3 or a problem / conflict with the commerce module.

As I don't have the skills to investigate deeper you find the export of the view with the duplicates at http://pastebin.com/NRnJPQgu and the working view at http://pastebin.com/32KZ4SNr .

I hope the description of the problem is understandable. If you need further information I would be lucky to deliver. And if it's just me who made an incredibly silly error - sorry for wasting your time.

But nonetheless thanks for this great module!

CommentFileSizeAuthor
#4 Screen Shot 2012-03-16 at 3.50.23 PM.png28.73 KBduskoo

Comments

davisben’s picture

Thanks for the detailed description! I'll get commerce setup on a test site and see if I can track this down.

futurist’s picture

I got duplicates of nodes too after adding weight as sorting criterion, without commerce. I posted in the Views issue queue because I'm not sure where this belongs. (I will gladly provide access to my dev site if it is of any use.)

pauleb’s picture

Do our node types with the problem have anything (field types, updated from weight-1.0) in common?

Some additional information on the fields on the node type where it worked:

  • title
  • body
  • 4 number fields (single value)
  • user reference (references module) to multiple users
duskoo’s picture

StatusFileSize
new28.73 KB

I've noticed that duplicate entries are being made in field_data_weight_table (after changing the initial weight for a node). In the attached screenshot, the original entry is in German, and the duplicate is undefined.

davisben’s picture

Thanks for the reports everyone! I haven't been able to reproduce this yet, but I'll be diving into it when I have some time this weekend.

pauleb/futurist - Are either of your sites multilingual also?

Helrunar’s picture

I think, i came a bit closer to this issue.

When you enabling the module for an contenttype without existing content, all will work fine and you got no duplicate content after saving the new weight. But, if you enabling the module for an contenttype with existing content, the existing content is not updating correctly and you've got duplicate entries after saving the weight.
I have test it on one page only in English and on one multilingual page with German as default language.

I hope this will help.

pauleb’s picture

My site is multilingual with German as default language and English also enabled.
Multilingual settings are disabled for both of the node types where I tried weight.

@Helrunar: On the other content type, where it worked, content already existed. I just added the weight functionality to the node type, cloned the weight - view and it worked with the existing content. I didn't add any new content to both of the node types when I was testing.

davisben’s picture

Status: Active » Fixed

I just committed a major overhaul to the weight field system that should eliminate this problem.

wiherek’s picture

will it be in the new dev? I am having the same problem.

davisben’s picture

Yes, it will be in the next dev release, but you can get it from git now if you don't want to wait for a few hours. Don't forget to backup your database and run update.php for all changes to take effect after updating the code.

wiherek’s picture

yea, I just did :)
I tried to install it upon the existing beta AND dev release and then update.php, but that returned fails. So I tried disabling then uninstalling the previous versions, and then installing the new commit. That required adding all the weight information and setting up views once more to sort by weight - but it works well! :)

Thanks a lot!

amerkelijn’s picture

This morning I installed the 7.x-2.0-beta3 version and got the problem of duplicates of nodes.
I just installed the dev version, run update.php and the duplicates are gone!

Thanks!!

knalstaaf’s picture

Notice: carefully uninstall the previous version. I was little too careless and simply deleted the folder, uploaded the new one and ran update.php. This resulted in the following error:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mink_batsup.weight_weights' doesn't exist: SELECT weight FROM {weight_weights} WHERE entity_id=:id AND entity_type=:type; Array ( [:id] => 84 [:type] => node ) in _weight_get_weight() (line 377 of /var/www/vhosts/domain.com/subdomains/preview/httpdocs/sites/all/modules/weight/weight.module).
The website encountered an unexpected error. Please try again later. 

If you bumped onto the same error, just delete the weight-folder again, refresh the website, upload the dev version, go to modules, and before enabling the dev version: uninstall the previous version. Then enable the dev version and you should be done.

knalstaaf’s picture

Status: Active » Needs review

Ow hold on, I'm getting this one now after saving content with weight (white page):

Fatal error: Call to undefined function weight_field_is_empty() in /var/www/vhosts/domain.com
/subdomains/preview/httpdocs/modules/field/field.module on line 523

Looks nasty.

Also getting this error randomly, related?

Error message
Notice: Undefined index: module in _field_info_prepare_instance_widget() (line 382 of /var/www/vhosts/domain.com/subdomains/preview/httpdocs/modules/field/field.info.inc).

And more:

Notice: Undefined index: weight_weight in _token_field_info() (line 1280 of /var/www/vhosts/domain.com/subdomains/preview/httpdocs/sites/all/modules/token/token.tokens.inc).

And this (after disabling, uninstalling and re-enabling the module):

Error message
Notice: Undefined index: enabled in weight_field_attach_form() (line 265 of /var/www/vhosts/batterysupplies.be/subdomains/preview/httpdocs/sites/all/modules/weight/weight.module).

Resulting in this beauty after saving weight-related content:

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] => 135 [:db_insert_placeholder_1] => node [:db_insert_placeholder_2] => ) in _weight_set_weight() (line 369 of /var/www/vhosts/domain.com/subdomains/preview/httpdocs/sites/all/modules/weight/weight.module).

Luckily I can still go to the edit page of that node, but guess what: the troublemaker escaped. No possibility to apply a weight on the node anymore.

Ok, uninstalling, deleting the dev version, and putting back the 7.x-2.0-beta3. Oops...
FieldException: Attempt to create field name <em class="placeholder">weight</em> which already exists, although it is inactive. in field_create_field() (line 81 of /var/www/vhosts/domain.com/subdomains/preview/httpdocs/modules/field/field.crud.inc).

Update.php?
No pending updates.

No possibility anymore to assign weight anymore. Guess it's all kaputt in my case now.

davisben’s picture

Status: Fixed » Active

I'm not sure where you stand at the moment, but it looks update.php didn't run completely and you're stuck in between the 2 versions of the module. Could you check your database to see which of the following tables exist?

  • weight_settings
  • weight_weights
  • field_data_weight
knalstaaf’s picture

Status: Needs review » Active

I can find these:

  • weight_settings
  • field_data_weight

But not this one: weight_weights

I notice in the field_data_weight that the language of modified nodes (assigned weight to these) has been switched to "und" instead of "en".

davisben’s picture

I would try setting schema_version to 7204 for the weight module in the system table, then try running update.php again. This should run the 2 updates that take care of creating the new table, populating it with the weights from field_data_weight, and removing all the old field related stuff.

knalstaaf’s picture

Status: Active » Fixed

Checked schema_version and strangely enough it was already set to 7204. Deleted 7.x-2.0-beta3 (couldn't uninstall after disabling it, because fields were being used). Uploaded the dev version, ran update.php, and this time the 2 required updates went well (whereas the first time it tripped over the second update).

Configured the proper content type again, tested it and not a single problem popped up. So I guess this is fixed.

Thanks for pulling me out, 10oclock!

knalstaaf’s picture

Status: Fixed » Active

I cheered too early I'm afraid.

I applied the dev version on two other websites (no earlier version was installed), and the issues occur again.

It starts with this error on the edit page of a node (that hasn't got weight enabled - which is weird):

Notice: Undefined index: enabled in weight_field_attach_form() (line 265 of /var/www/vhosts/domain.com/httpdocs/sites/all/modules/weight/weight.module).

When hitting "Save" on the edit page, this error occurs:
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] => 84 [:db_insert_placeholder_1] => node [:db_insert_placeholder_2] => ) in _weight_set_weight() (line 369 of /var/www/vhosts/domain.com/subdomains/preview/httpdocs/sites/all/modules/weight/weight.module).

When I checked back to the site of yesterday, I see that this behaviour is also present there (again). I've checked in another browser, just in case it had something to do with the browser's cache, and it's also doing it there.

-> The remarkable thing is: it doesn't occur on pages that do have weight enabled.

davisben’s picture

Version: 7.x-2.0-beta3 » 7.x-2.x-dev
Status: Active » Fixed

I found the bug, and committed the fix. It will be included in the next dev release, but you can get it from git now.

Status: Fixed » Closed (fixed)

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

Yuri’s picture

Status: Closed (fixed) » Active

This looks very much like the error mentioned here.
I got this when resaving a node (after changing the image in an image field.)
latest version of Weight.

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] => 5 [:db_insert_placeholder_1] => node [:db_insert_placeholder_2] => ) in _weight_set_weight() (line 434 of /home/groups/public_html/sites/all/modules/weight/weight.module).
davisben’s picture

I'm currently traveling, but will check this out next week.

davisben’s picture

That looks like the same error mentioned in #8 at #1589932: Weight not saving default value. Are you using the most recent dev version?

davisben’s picture

Status: Active » Closed (cannot reproduce)

If anyone is still experiencing this with the latest release, please reopen this issue.