i have included a patch that fixes a few bugs we found

1st bug: upon node_load, weight is not loaded correctly because the used variable is null;

      $node->sticky = ($sticky > 0) ? 1 : 0;
      $node->node_weight = _real_sticky2weight($sticky);

The variable $sticky is not set within the scope of the function. The correct variable is, ofcourse, $node->sticky

2nd part of the patch implements your 'to_do':

function _change_weight; comment: this is a lot of unnecessary overhead. TODO: just do DB calls

3rd path of the patch is a bugfix again;
$sticky is a number, either < 0, == 0 or > 0
the following statement is true when $sticky is set and PHP finds that == 0 means false, all else is true
if ( $sticky ) evaluates negative numbers as being positive, a.k.a. all nodes are evaluated as sticky
the correct condition is ofcourse:
if ( $sticky > 0)

Hoping to be of service;

Remon.

CommentFileSizeAuthor
weight.module.patch1.17 KBrmpel

Comments

rmpel’s picture

the following statement is true when $sticky is set and PHP finds that == 0 means false, all else is true
" if ( $sticky ) " evaluates negative numbers as being positive, a.k.a. all nodes are evaluated as sticky
the correct condition is ofcourse:

The correct phrase is ofcourse;
if ($sticky) evaluates positive and negative numbers as true and therefore processing them equally; as being positive.

rmpel’s picture

Status: Active » Closed (fixed)

No comments for a long time. Issue is, however, fixed in newer version.

Closed.