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

User interface changes

None

API changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott’s picture

Issue summary: View changes
cs_shadow’s picture

Status: Active » Needs review
FileSize
595 bytes

Attaching the patch though it doesn't seems to be a documentation issue. \Drupal::config('vote.settings').get('score_max') is part of actual code.

alexpott’s picture

@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 :)

cs_shadow’s picture

@alexpott got it. Thanks :)

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! Looks correct to me.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

  • Commit 9528f21 on 8.x by webchick:
    Issue #2240019 by cs_shadow | alexpott: Incorrect API documentation in...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.