To reproduce, set a node's weight to be -15 on a -20-->20 scaled node. Now go to admin/node/weight and find the node -- it probably shows -20 even though the value in the database is correct. The SQL in function weight_manager() is returning huge positive numbers for negative weighted items because ABS() must be returning an UNSIGNED INTEGER value.

To fix the problem, CAST the return value from ABS to SIGNED INTEGER. This changes the SQL to:

SELECT n.nid, n.title, n.type, n.uid, u.name author, n.sticky AS stored_sticky, CAST( ABS( n.sticky ) AS SIGNED INTEGER ) -100 AS weight, n.created
FROM {node} n
LEFT JOIN users u ON u.uid = n.uid

NOTE: I am running MySQL version 4.1 -- maybe this isn't an issue with MySQL version 5.0?

I'm attaching a patch that fixes this.

CommentFileSizeAuthor
negative-weight.patch567 bytesmarcp

Comments

marcp’s picture

Status: Active » Needs review

Set status to patch (code needs review)

harry slaughter’s picture

Status: Needs review » Closed (fixed)

I'm not able to reproduce this in 4.7. In 5.0 it's no longer relevant because that query is no longer being run.

harry slaughter’s picture

Status: Closed (fixed) » Fixed

It could very well be a problem with mysql4 only. I'll apply patch to 4.7 and assume it fixes a problem I can't see.

Anonymous’s picture

Status: Fixed » Closed (fixed)