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.
| Comment | File | Size | Author |
|---|---|---|---|
| negative-weight.patch | 567 bytes | marcp |
Comments
Comment #1
marcp commentedSet status to patch (code needs review)
Comment #2
harry slaughterI'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.
Comment #3
harry slaughterIt 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.
Comment #4
(not verified) commented