Problem/Motivation
Inaccurate documentation for 8.2.x
API page: https://api.drupal.org/api/drupal/core%21modules%21views%21views.api.php...
> The field module's implementation of hook_views_data() invokes this for each field storage, in the module that defines the field type. It is not invoked in other modules.
Field module no longer implements this hook in D8. Views invokes this in views_views_data().
Proposed resolution
Update documentation to reflect that Field module no longer implements this hook in D8.
Remaining tasks
Update documentation
User interface changes
-
API changes
-
Data model changes
-
| Comment | File | Size | Author |
|---|---|---|---|
| #60 | inaccurate_docs_for-2730227-51.patch | 1.39 KB | quietone |
| #51 | inaccurate_docs_for-2730227-51.patch | 1.39 KB | izus |
| #51 | interdiff_49-51.txt | 1.59 KB | izus |
| #49 | interdiff_47-49.txt | 1.43 KB | izus |
| #49 | inaccurate_docs_for-2730227-49.patch | 2.04 KB | izus |
Comments
Comment #2
kellyimagined commentedComment #3
kellyimagined commentedWorking on a solution for this issue.
Comment #4
kellyimagined commentedUpdated documentation.
Comment #5
kellyimagined commentedComment #7
dagmar@kellyimagined you are creating the patch in some wrong way. Try with this:
Comment #8
kellyimagined commented@dagmar,
Thank you for the feedback, please let me know if this works.
Comment #9
kellyimagined commentedComment #11
kellyimagined commented@dagmar,
I must have a love for punishment. Maybe you can tell me why it is failing?
Comment #12
kellyimagined commentedComment #14
kellyimagined commentedUpdated according to docs and removed white space according to fail.
Comment #15
mile23Comment #16
jhodgdonGood catch, and thanks for the patches!
However, the latest one still needs some work:
The first sentence is not grammatical, and it doesn't make sense to me.
Also, we don't want to document history in the API docs. So remove the part about "no longer". Just document what is currently true.
Also, incidentally, please don't use the 'documentation' tag in Drupal Core. See https://www.drupal.org/node/1208166 .
Comment #17
snehi commentedModified.
Comment #18
jhodgdonNo, this is not accurate either. This is not a hook implementation at all, it's documentation for a hook.
I think what we need to do is to replace this text:
with something like this:
When collecting the views data, views_views_data() invokes this hook for each field storage definition, on the module that provides the field storage definition. If the return value is empty, the result of views_field_default_views_data() is used instead. Then the result is altered by invoking hook_field_views_data_alter() on all modules.
Comment #19
jhodgdonIt also seems that hook_field_views_data_views_data_alter() is no longer invoked. And the documentation for hook_field_views_data_alter() needs a similar fix to this issue. I think we should combine all of that into one issue/patch?
Comment #20
jhodgdonComment #21
kellyimagined commented@jhodgdon, is this what you are requesting?
Comment #22
jhodgdonClose, thanks!
A few things to address:
This section needs to be rewrapped. We want all documentation lines to be less than 80 characters.
I think this is the docs header for hook_field_views_data_views_data_alter()... I had thought that this hook should be removed, but I was wrong about that. It does need an update though, but exactly not this update. What it needs to say instead is that it is invoked on the module that provides the field storage definition, and that it is invoked from views_views_data_alter().
Comment #23
Sonal.Sangale commentedComment #24
Sonal.Sangale commentedHi jhodgdon,
Can you please elaborate second point of suggestion as it is little confusing ?
Comment #25
jhodgdonSure, and sorry!
OK. Ignore comment #22. Here is hopefully some clearer information.
So we have 3 hooks:
a) hook_field_views_data() -- this hook documentation header needs the fix in the #21 patch (but all documentation needs to be wrapped to 80 character lines).
b) hook_field_views_data_alter() -- needs a fix similar to hook_field_views_data() -- but not exactly, because the text says "this hook" (referring to hook_field_views_data() in that text) -- so it needs a small edit so it is relevant to hook_field_views_data_alter() instead of hook_field_views_data(). Note that the patch in #21, by mistake, put the fix in the wrong this documentation header (see (c) below).
c) hook_field_views_data_views_data_alter() -- This hook documentation was mistakenly changed in the last patch. It does need a change, but the text that was put in there was for the wrong hook. What it needs instead is some text saying that it is that it is invoked from views_views_data_alter(), and only invoked on the module that provides the field storage definition.
Thanks! Hope this is clearer.
Comment #26
Sonal.Sangale commentedGiven it a try!
Please review.
Comment #27
jhodgdonThanks for trying, but this isn't quite right.
Looking at #25...
a) Looks good.
b) This wasn't done at all.
c)
This part about the return value doesn't apply to this hook.
Comment #28
Sonal.Sangale commentedComment #29
mohit_aghera commented@jhodgdon
Updated patch as per your suggestion.
Removed c point changes from patch (https://www.drupal.org/node/2730227#comment-11225311) .
Fix other comment.
Comment #30
mparker17Unassigned as @mohit_aghera has already uploaded a patch for review, and he can't review his own patch :) Also, I'm hoping that someone will be able to review this at the Drupal North 2016 coding sprint tomorrow.
Comment #31
wolffereast commentedPoints a and b look alright, but we are still missing point c in it's entirety.
Comment #32
swarad07As suggested by jhodgdon in #25, made changes to docs of hook_field_views_data_views_data_alter().
Comment #33
swarad07Some empty spaces seem to have crept in.
Comment #34
swarad07Removing empty spaces.
Comment #35
swarad07Comment #38
zeip commentedFixed a typo.
Comment #41
impalash commented@jhodgdon fixed for 8.6.x please review.
Comment #43
joachim commentedI don't think this implementation exists any more.
So it's possible this hook no longer exists either!
I would say the changes to this hook are out of scope for this issue. The rest of the patch looks fine.
So next steps:
- reroll the patch minus the changes to hook_field_views_data_views_data_alter()
- file a new issue about hook_field_views_data_views_data_alter()
Comment #44
izus commentedHi,
- here is a reroll minus hook_field_views_data_views_data_alter() as suggested in #43
- the new issue about hook_field_views_data_views_data_alter() : https://www.drupal.org/project/drupal/issues/2999325
Thanks
Comment #45
joachim commentedLatest patch doesn't seem right -- we've lost the first hunk, at line 505, which is the one we mostly need.
Comment #46
joachim commented> - file a new issue about hook_field_views_data_views_data_alter()
On second thoughts, let's keep it here.
hook_field_views_data_views_data_alter() *does* still exist. Some core modules implement it. The docs are wrong in the same way as for hook_field_views_data():
That paragraph is wrong. The code that invokes this is now in Views:
Comment #47
izus commentedHi,
Thanks for the review
here is another try :)
Comment #48
joachim commentedNearly there I think!
I'd like it if we were consistent here -- either just say the name of the function, or say "The Views module's implementation of hook_NAME() invokes...".
Or combine both for clarity:
"The Views module's implementation of hook_NAME(), views_NAME(), invokes ... ".
This change should be removed.
The original text is correct.
Comment #49
izus commentedHere it is :)
Comment #50
joachim commentedWe've lost the 'It is not invoked in other modules' sentence, and the paragraph break.
We've lost lots of the text here.
This change is just changing wrapping.
Comment #51
izus commentedHi,
thanks for the review :)
Here it is
Comment #58
quietone commentedPatch applies to 9.4.x. The text changes look fine to me but I'll ask in #bugsmash for a second opinion.
Comment #59
lendudeGave it a detailed read and checked the logic to make sure it still matches what happens in
views_views_data()andviews_views_data_alter()and it does, so this looks good to me.Comment #60
quietone commentedRe-uploading the patch so it tests with 9.4.x
Comment #62
longwaveRandom fail.
Comment #63
alexpottCommitted and pushed 9b9dc205ec to 10.0.x and be38b68647 to 9.4.x and 6e7d1e6e21 to 9.3.x. Thanks!