Field context module provides a way for developers to reference field instances in abstract terms rather than actual field names, allowing to write a future-proof code in cases where exact field names need to be known.
The target audience of this module are developers. Possible use case is described on the project page. The module contains tests for core module functionality.
Note: This module does not have a relation to Context module. It merely uses the word "context" to describe that an abstract meaning (a context) can be assigned to a field.
Project page: https://drupal.org/sandbox/maijs/2265069
Git:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/maijs/2265069.git fieldcontext
cd fieldcontextProject is successfully reviewed by http://pareview.sh (see results).
Reviews of other projects:
- [D7] MyCharts module - https://drupal.org/node/2266047#comment-8778981
- [D7] search_replace_blocks_menus - https://drupal.org/node/2267323#comment-8779835
- [D7] labelvalue - https://drupal.org/node/2268405#comment-8784887
| Comment | File | Size | Author |
|---|---|---|---|
| field-context-ui.png | 40.4 KB | maijs |
Comments
Comment #1
maris.abols commentedTested on clean environment and got the same results I expected from provided Use case. Also code looks good.
Feature export/import works just fine.
I havn't tested predefined contexts, but otherwise module looks really good.
Comment #2
maijs commentedComment #3
maijs commentedPAReview: review bonus tag added.
Comment #4
maijs commentedI'm bumping the priority as per https://drupal.org/node/539608 (Technically this issue is RTBC, but it has been reviewed by only one d.org user.)
Comment #5
donSchoe commentedChecked working:
$wrapperon a line above the conditional for better readability.Needs work:
field_context_. I'd prefer the 2nd approach.Comment #6
maijs commented@donSchoe, thanks for review!
field_contextand it seemed to be a good name as it separates the words with an underscore. I changed the name tofieldcontextafterwards because of marginally possible namespace conflict with core modulefieldand contrib modulecontext. Functionfield_context_get_field_name()does indeed look like some sort ofcontextmodule related hook infieldmodule.Fieldcontextas a module title on it's own does not seem to be readable.preg_matchparameter, so that if you have multiple fields with, say, date values and you assign contextsthis_dateandthat_dateto them, you can then get all the date related field names withfieldcontext_get_field_name_multiple('/[\s]?date/i', $entity_name, $bundle, TRUE);and use it where they're needed.I'm putting back Needs review status as review remarks are explained.
Comment #7
donSchoe commentedSorry, there was place for misunderstanding, when I wrote:
I'm not talking about site builders, administrators or developers, I'm talking about users in terms of entities. You know, for node types this module makes sense in my eyes, but for user entities I can't imagine a use case.
That's what I ment. Sorry for the confusion. I'm not questioning this module in general! I like the idea and approach.
I'm fine with (1.) if you rename your module to Fieldcontext. This would be consequent.
Comment #8
maijs commentedThere might be use cases for any fieldable entity, but I agree that this module has limited usage potential for
userentity given that it only has oneuserbundle.There are many contibuted modules with names that are not identical to module titles in snake case (
module_title_name), for example, XML sitemap (xmlsitemap), Localization update (l10n_update), Global Redirect (globalredirect), Entity reference (entityreference).I believe that the current choice of module title is appropriate. Words
Fieldandcontextare two distinct words, that make sense if separated by a space. As I mentioned in previous comment, the reason for usingfieldcontextmodule name was practical (so that developers are not confused) rather than aesthetic (just because I prefer it that way), therefore there is no reason to forcefully change the module title for the sake of having it the same as module name. It's only a space.Minor warning, that has been raised by Coder module, has been resolved.
Comment #9
gisleAutomated Review
PAReview came up clean.
Manual Review
@paramand@returnaccording to the API documentation and comment standards. In particular, the API functions offered by the module need to have this documentation to be usable by others. This omission also makes manual review difficult, as the reviewer must in some cases guess what the intent of function is.hook_help(). It is good coding practice to have this hook for every enabled module.The starred item (*) is a fairly big issue and warrant going back to Needs Work. The rest of the comments in the code walkthrough are recommendations.
Comment #10
maijs commentedgisle, thanks for review!
Three things:
hook_help()implemented. Agree that it's good practice to include it.Comment #11
gisleManual review
(Doesn't repeat items given "Yes"-status from last review.)
hook_help()is now available.hook_help()for the sub-module Field context Test, nor is there any mention of it in README.txt. It is pretty obvious what it does, but it should at least be a brief mention of its existence in README.txt.tests/fieldcontext_test/. It is tiny, only 3 files with a total of 278 lines (including comments). I do not see the point of burying it that deep below the main project directory. Why don't it live in the project directory, or (if a more "tests" will be added later) in the sub-directorytests/)?This in turn creates a situation where the sub-module is installed, but the database is not necessarily in the state it expects it to be.
The reason I got this particular error is of course because I'd already worked through the example use case from README.txt (i.e. I'd already created
field_painting_price"by hand"). However, the sub-module should handle the situation where the field it tries to a create a field that already exists more gracefully (e.g. check for existing fields before creating anything, and abort the installation if a field it wants to create already exists, giving the user a meaningful message about how to recover).The starred item (*) is a fairly big issue and warrant going back to Needs Work. The rest of the comments in the code walkthrough are recommendations.
Comment #12
maijs commentedGisle, good points all around!
Field contextpackage in module listing. Having them both inOtherpackage seems like polluting the package space.tests/fieldcontext_test/directory totests/directory. Indeed there is no need to nest too deep.hook_help()implemented for Field context Test sub-module._testsuffix to names of content types and fields created by Field content Test module to avoid name collision in case user haddrawingorpaintingcontent types defined prior to enabling the module that have nothing to do with this module or testing.Comment #13
gisleManual review
(Doesn't repeat items given "Yes"-status from previous reviews.)
tests/.There is no need to pass
form_stateby reference here:This is not a blocker, tho'. Moving to RTBC. Note that promotion will not happen until a git administrator has given this a second set of eyes.
Comment #14
maijs commentedgisle, you've done a comprehensive review of the module and I thank you for that.
It is a common practice to have
$form_statepassed by reference in validation functions, even if function itself does not alter the$form_state. See, for example,node_type_form_validate()and other validation functions in core.Comment #15
mpdonadioUpdated git clone to public URL.
Comment #16
maijs commentedProject name changed in git clone command from
field_contexttofieldcontext.Comment #17
mpdonadioAutomated Review
Review of the 7.x-1.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Manual Review
Tests threw some notices about Array to string conversion on line 45. All passed on a clear D7.28 install.
Test coverage looks OK.
In fieldcontext_help(), build the URL with l() and pass that as a parameter to t().Ignore this. I forgot about this usage.Can you leverage cache_get() / cache_set() anywhere?
I wonder is fieldcontext is the best namespace, as Context is fairly ubiquitous. Think pretty hard about this, as
changing it will be impossible once you promote it. A variant of field alias seems logical, but there is already
a module with this name (that looks like it does something totally different).
Agree with @maijs, padding $form_state by reference is the normal thing in validate and submit handlers.
I am not seeing any blocking issues. This looks pretty well written w/ a good use of comments and includes tests. It also looks like @gisle has given this
a thorough look.
Comment #18
mpdonadioThanks for your contribution, maijs!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #19
maijs commentedMatthew, thanks for your feedback on Field context module. You expressed your concern regarding the module name, namely that it implies connection with Context module, and I agree that it does. What you think a proper module name should be for the module then?
field_abstractfield_conceptfield_metaComment #20
mpdonadioNot sure (and see my amended comments above, I had a brainfart when I did the review). I kinda like "metafields".