Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This issue has novice tasks. If you are an experienced core developer and have multiple commit mentions, please review novices' work on these tasks rather than doing them yourself. Feedback from experienced contributors is valued.
Problem/Motivation
function hook_ranking() {
// If voting is disabled, we can avoid returning the array, no hard feelings.
if (\Drupal::config('vote.settings')->get('node_enabled')) {
return array(
'vote_average' => array(
'title' => t('Average vote'),
// Note that we use i.sid, the search index's search item id, rather than
// n.nid.
'join' => 'LEFT JOIN {vote_node_data} vote_node_data ON vote_node_data.nid = i.sid',
// The highest possible score should be 1, and the lowest possible score,
// always 0, should be 0.
'score' => 'vote_node_data.average / CAST(%f AS DECIMAL)',
// Pass in the highest possible voting score as a decimal argument.
'arguments' => array(\Drupal::config('vote.settings').get('score_max')),
),
);
}
}
\Drupal::config('vote.settings').get('score_max')
is wrong. Should be \Drupal::config('vote.settings')->get('score_max')
Proposed resolution
Fix code
Remaining tasks
- Write patch (novice)
- Review patch to check it fixes the issue, the change is properly documented and for coding standards. Provide test evidence (novice)
- Keep issue summary up to date (novice)
User interface changes
None
API changes
None
Comment | File | Size | Author |
---|---|---|---|
#2 | drupal-fix_documentation_in_hook_ranking-2240019-1.patch | 595 bytes | cs_shadow |
Comments
Comment #1
alexpottComment #2
cs_shadow CreditAttribution: cs_shadow commentedAttaching the patch though it doesn't seems to be a documentation issue.
\Drupal::config('vote.settings').get('score_max')
is part of actual code.Comment #3
alexpott@cs_shadow core/modules/node/node.api.php is a documentation file - this code is never run at runtime it is an example hook implementation :)
Comment #4
cs_shadow CreditAttribution: cs_shadow commented@alexpott got it. Thanks :)
Comment #5
jhodgdonThanks! Looks correct to me.
Comment #6
webchickCommitted and pushed to 8.x. Thanks!