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.
hook_field_storage_load() has 5 parameters but the last one ($options) is not documented..
Comment | File | Size | Author |
---|---|---|---|
#19 | 752296-fixdoc.patch.patch | 8.75 KB | yched |
#17 | 752296-fixdoc.patch.patch | 6.9 KB | yched |
#10 | 752296-fixdoc.patch | 6.93 KB | jhodgdon |
#8 | field_load_options-752296-8.patch | 5.48 KB | yched |
#6 | field_load_options-752296-6.patch | 4.13 KB | yched |
Comments
Comment #1
jhodgdonGood catch! It does indeed look like the implementations of hook_field_storage_load() use a $options parameter, and this is not on the hook doc page. The hook is invoked from field_attach_load(), which is definitely passing in $options.
See
http://api.drupal.org/api/function/hook_field_storage_load/7
http://api.drupal.org/api/function/field_sql_storage_field_storage_load/7
http://api.drupal.org/api/function/field_attach_load/7
Comment #2
yched CreditAttribution: yched commentedThis is also true of hook_field_storage_pre_load().
field_attach_load() calls it with the $options param, which is not documented in the hook's PHPdoc
http://api.drupal.org/api/function/hook_field_storage_pre_load/7
Comment #3
yched CreditAttribution: yched commentedAdds docs for missing params and fixes a couple formatting errors (80 chars wrapping, indentation)
Comment #5
jhodgdonThe test failure looks like something unrelated to this patch.
That aside, a couple of things to fix in the patch:
a) Need a blank line between @param section and @return in all functions. See http://drupal.org/node/1354
b)
deleted field -> deleted fields ? This occurs in a couple of functions.
c)
This doesn't look like it describes the return value -- what is the return value, or is there a return value? And what is this referring to really?
This applies to the next function as well.
d)
ids -> IDs ... or maybe it should be ID without the s?
associated to -> associated with
Comment #6
yched CreditAttribution: yched commenteda) all functions under modules/field/ currently skip that convention. Added the empty line for the functions touched in the patch, but adjusting the remaining 99,9% is out of scope here ;-).
b) fixed
c) Those functions only act by altering the incoming params by reference. Documenting those expected side-effects in the @return section is, AFAIK, common practice in the rest of core, but I might be proven wrong.
Here also, this is used in many other places in field module.
d) 'ids' is also used all over the place in field module, out of scope for this patch.
Comment #7
jhodgdonUmmm...
- @return is for return values, period. Use the main section of the doc to describe what the function does, if there is no return value.
- "ids" violates standard English usage.
I realize that there is a lot of doc in core that is in violation of our coding and style standards. The fact that a violation of coding standards is "common practice" is not really a good excuse for committing doc patches that leave the doc out of compliance with our standards. I'm not asking for anyone to go and fix an entire file's worth of functions, but at least when we are touching the doc of particular functions, we can bring them into compliance. Please? :)
Comment #8
yched CreditAttribution: yched commentedI don't agree, esp on the '@return is for return values, period. Use the main section of the doc to describe what the function does, if there is no return value' item. This obfuscates the "contract", which lies in the @param, @result sections. If @return is not the place to document side effects (params altered by ref, exceptions...), then there should be another @section dedicated for this.
However, you're the boss :-).
Comment #9
jhodgdonIt's not that I'm the boss. It's that our coding standards, based on industry standards, http://drupal.org/node/1354#functions say:
I would say the side effect here should also be noted on the entities @param, because that is what is being altered, correct?
That aside, this doc needs some English style/grammar/usage/clarity editing, for things like "need to added" and "entity type of entity". I will take a try at rewriting it on Monday, unless someone gets to it before me.
Comment #10
jhodgdonHere's a patch that fixes up the doc, I hope.
Comment #11
yched CreditAttribution: yched commented"shard" is the intended word here.
http://en.wikipedia.org/wiki/Shard_%28database_architecture%29
Other than that, RTBC.
Powered by Dreditor.
Comment #12
jhodgdonAh. Little did I know...
It looks like "shard" is mostly a noun, not a verb, though. So should it be "lets modules override, mirror, use a shard, or ..." ?
Comment #13
yched CreditAttribution: yched commentedThis is not my comment, I didn't know that term either before bjaspan explained it to me :-).
That same page mentions 'database sharding', and a google search on this expression brings 47 000 answers, so i guess the verb is ok too.
Comment #14
jhodgdonGoogle would treat "shard" "shards" "sharding" etc. as the same term for purposes of searching, by the way. So if you typed in "sharding" that would also bring up pages that only used it as the noun shard/shards, and having 47000 results for "sharding" doesn't conclusively mean it's a verb.
But I do see "sharding" on the Wikipedia page, although it's just used as a gerund-like for the action of making a shard and not technically as a verb... But fine. Guess that needs to get changed back.
Comment #15
yched CreditAttribution: yched commentedre google # of results : Don't want to sound anal, but I don't think it's true if you use exact search of an expression with double quotes.
Comment #16
jhodgdonI sit corrected.
Comment #17
yched CreditAttribution: yched commentedRerolled #10 without the 'shard' / 'share' replace.
Comment #18
jhodgdonYou know... we should probably say "loaded" instead of "returned in this section at the end of the first hook:
And here in the second hook:
And in field_attach_load(), we should probably add a note in @param $entities that says the fields are loaded directly there, even though it's stated above...
Comment #19
yched CreditAttribution: yched commentedDone.
Also updated field_attach_revisions() phpdoc accordingly, and fixed 80 chars wrapping over there.
Comment #20
jhodgdonExcellent work!
Comment #21
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD.