Reference to a not initialized variable in flag_weights_set_flag()
hefox - June 25, 2009 - 02:13
| Project: | Flag Weights |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
In flag_weights_set_flag it says $handlers instead of $handler when calling flag_weights_set_weight ( $handlers->content_type). Can't see anywhere else where $handlers is used; if this is related to how the module is used, then close this but I can't imagine how that ever worked.
In related (aka how I noticed the typo) popped out this function to flag/weight using an existing flag. (The flag using content type never worked for me btw, don't currently really see the purpose of it).
<?php
function flag_weights_set_flag_with_flag($flag_name, $content_id, $account = NULL, $weight = 0) {
$handler = flag_get_flag($flag_name) ;
$ok = $handler->flag('flag', $content_id, $account);
if ($ok && $weight != 0) {
if (!isset($account)) {
$account = $GLOBALS['user'];
}
flag_weights_set_weight($handler->fid, $handler->content_type, $content_id, $account->uid, $weight);
}
return $ok;
}
?>
#1
#2
<?php- flag_weights_set_weight($handler->fid, $handlers->content_type, $content_id, $account->uid, $weight);
+ flag_weights_set_weight($handler->fid, $handler->content_type, $content_id, $account->uid, $weight);
?>
Please, let me know if you wish a proper patch for this.
#3
Applied the handler/handlers patch to -dev.
Will consider the new function another day (setting back to "needs review"). Thanks!
#4
Committed a new method as described above. Agree that flagging by flag-name makes more sense than by content-type, but changing the API now would break anyone who is using it, in unexpected ways.
http://drupal.org/cvs?commit=256248
#5
Automatically closed -- issue fixed for 2 weeks with no activity.