Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
documentation
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
20 Apr 2010 at 23:50 UTC
Updated:
6 May 2010 at 22:00 UTC
Jump to comment: Most recent file
hook_field_languages [see function field_multilingual_available_languages() in modules/field/field.multilingual.inc]
Part of #675046: Make sure all hooks in D7 have documentation
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 776982.patch | 1.22 KB | robeano |
Comments
Comment #1
robeano commentedActually, modules/field/field.multilingual.inc has changed a little. It looks like there are two alters now:
hook_field_available_languages_alter() called in field_available_languages()
and
hook_field_language_alter() called in field_language()
I will document both.
Comment #2
robeano commentedOops. My mistake...I missed the module_implements(), and it really is in field_multilingual_available_languages(). Please disregard comment #776982-1: hook_field_languages() is not documented
Comment #3
puregin commentedIt looks like this was fixed at some point. I updated the description for both hook_field_language_alter() and hook_field_available_languages_alter() in field.api.php in the course of cleanup for issue #776694: hook_field_attach_purge is not documented.
Marking as fixed...
Comment #4
robeano commentedThis isn't fixed. hook_field_languages() has not been documented yet. I am working on a patch now.
Comment #5
robeano commentedPatch provides documentation for hook_field_languages. Ready for review.
Comment #6
robeano commentedDarn it. I forgot to change the status.
Comment #8
jhodgdon#5: 776982.patch queued for re-testing.
Comment #9
jhodgdonThose test failures are not caused by this patch.
Reviewing the patch...
$language is defined as:
"An array of language preferences which will be intersected with the enabled languages."
I don't know what this means. Are they strings, or language objects? What does intersected mean? And the example function body has a comment saying an unavailable language is added -- what will that do if there is some kind of intersection with available languages?
Also, a puncuation note: you need a comma before a "which". :)
Comment #10
blg@bgreenaway.com commentedjhodgdon, the $languages detail is too specific here, right?
Array intersection is merely one thing that could be performed by this hook, but seems by no means required.
Trivially, having data passed in to a custom function merely makes it available to that function for working with (or perhaps operating on, but that should be handled under an hook_alter method.) Intersection would give you a common denominator of equally set values ignoring ones unique to a single language, but the hook _could_ do other things, like color code everything blue if Chinese translation is set for Mandarin rather than Wu...?
Point's not that $languages will be intersected and what happens if (eg the expected return of the intersected array objects) but that $languages is being passed into the function body and the docs should say what it is.
So I think it will be sufficient to write,
+ * @param $languages
+ * An array of language preferences.
or maybe
+ * @param $languages
+ * The complete array of language preference settings for your site.
(if indeed it is)
Again, sorry I can't make/attach my suggested patch but this would take longer than this posting and might delay the fix. (I'll check back later when I've worked out a patch build process.)
Comment #11
jhodgdonThat comment on #1 is correct -- hook_field_languages() doesn't appear to exist, nor does the function that used to invoke it.
So, this is no longer an issue. The other two hooks identified in #1 have already been documented.