I just spent the last couple hours trying to figure out why I was getting a non-sensical SQL error during searches. While looking into it, I finally discovered that the problem is that the documentation for hook_ranking() (both D7 and D8) has incorrect instructions (and example) for how to use the 'join' key. It says that the 'join' value should be a string that will be merged into the SQL query, when in fact it needs to be an array of values, like below:
'join' => array(
'type' => 'LEFT',
'table' => 'node_counter',
'alias' => 'node_counter',
'on' => 'node_counter.nid = i.sid',
)
I discovered this by looking through core for implementations of hook_ranking()
that use the 'join' key, and found one in statistics.module. That led me to finally understand what's happening in node.module's _node_rankings()
function, and why that array is needed.
My guess is that at some point in the development process for the ranking hook system, the 'join' key was changed to an array, but the documentation was never updated.
Beta phase evaluation
Issue category | Bug |
---|---|
Issue priority | Major because API documentation is incorrect |
Unfrozen changes | Unfrozen because it only changes incorrect API documentation |
Prioritized changes | The main goal of this issue is fixing broken documentation. |
Comment | File | Size | Author |
---|---|---|---|
#7 | 2017433-7-hook_ranking-doccumentation.patch | 1.42 KB | LinL |
#1 | 2017433-1-hook_ranking-doccumentation.patch | 1.44 KB | BarisW |
Comments
Comment #1
BarisW CreditAttribution: BarisW commentedGood catch, here's the patch for D8. Needs backport to D7.
Comment #2
j. ayen green CreditAttribution: j. ayen green commentedComment #3
xjm(Merging "node system" and "node.module" components for 8.x; disregard.)
Comment #4
jhedstrom#1 looks good to me. Adding the docs tag, and a beta phase evaluation.
(I think API documentation bugs are major).
Comment #5
alexpottCommitted 8790ec0 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation for to the issue summary.
Comment #7
LinL CreditAttribution: LinL commentedHere's a backport for 7.
Comment #8
xjmComment #9
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer commented#7 looks good to me.
Comment #10
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedCommitted to 7.x - thanks!