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.
From webchick in #369562: Field: Trivial cleanup
"it would be wonderful to have a fields in core sprint attendee do a "TODO" pass and just make sure the list matches our actual remaining todos"
Comment | File | Size | Author |
---|---|---|---|
#19 | field_crud_disabled.patch | 2.32 KB | fgm |
#17 | field_crud-372330-17.patch | 5.43 KB | yched |
#16 | 372330.patch | 3.71 KB | fgm |
#11 | field_crud.patch | 3.62 KB | fgm |
#9 | field_crud.patch | 4 KB | fgm |
Comments
Comment #1
yched CreditAttribution: yched commentedComment #2
crotown CreditAttribution: crotown commentedI'll take this on and post what I find when I'm done.
Comment #3
crotown CreditAttribution: crotown commentedI updated my view of HEAD a few minutes ago and there are 89 occurrences of "TODO" in the Field module. Now I need to know where the current TODO list is located so I can compare. Anyone? Thanks in advance!
Comment #4
crotown CreditAttribution: crotown commentedbjaspan (over IRC) thought that this issues is more involved than a 2. He suggested I look through the TODO and fix what I can and post patches, so that will be my approach. As possible, I will look to comparing with the issue queue open issues at http://drupal.org/project/issues/drupal?status=Open&priorities=All&categ..., but as he suggested, that may be a bit much for me as a newcomer...
Comment #5
crotown CreditAttribution: crotown commentedI'm not getting to this in a timely fashion, and many of the TODO comments require advanced knowledge of the Field API, who is working on what, etc... So I am returning this one to the larger group.
Comment #6
fgmNot sure whether this is the proper issue, but here is one patch for one of the TODOs: the one about field name length.
Comment #7
fgmIn addition, fixing this made me wonder: currently, nothing prevents field_create_field from creating fields with names starting with a number instead of [a-z_]. Shouldn't this be prevented ?
Comment #8
yched CreditAttribution: yched commentedThe patch looks good. Can we just add a corresponding test in 'Field CRUD tests' ? I think there's a
// TODO: test other failures
line in there.You're perfectly right that we should prevent field names starting with a number. It would turn into invalid $object->1_foo properties and $1_foo variable names in templates.
Care to roll that in your patch ?
Comment #9
fgmHere is a revised version. It now checks the start character.
I've also added simpletest for illegal field names (non-alpha first char, and non-alnum other char).
I've also added a test for the field name length, however here I ran into a limitation of the simpletest mechanism (see patch for details) and had to remove that test. Not sure there is an actual solution, and it would likely have to be at the simpletest level anyway.
Comment #10
yched CreditAttribution: yched commentedHeh, true... well, I think we need to forget about that specific test, then. Not *that* bad. Let's just leave a comment on why we don't test this...
Other than that, looks ready to me.
Comment #11
fgmRerolled with just a comment instead of the test.
Comment #12
yched CreditAttribution: yched commentedGreat, only minor nitpicking now.
Comments should wrap at 80 characters. The 1st line above is too short, the other too long ;-)
Missing period at the end of the sentence. Also, I'm not sure 'alnum' abbreviation is good practice, we usually avoid abbreviations in comments.
This review is powered by Dreditor.
Comment #13
yched CreditAttribution: yched commentedHm, I might have replied a little too fast in #10. Actually I don't understand why we couldn't test that a field name > 32 chars fails : it's supposed to raise an exception before it reaches the point where a table would be created, so we shouldn't care that MySQL would fail to create the table because of simpletest prefix ?
Comment #14
fgmIt fails if we test it with a name that should be valid, because it is 31 characters long: in that case, the assertion succeeds and processing continues to create the field, triggering the mysql error because the table name is now 65 (minimum) characters long. This is not demonstrated by the test in its current state, though, only by the "positive" test which I wrote and removed before committing, which tests that creation succeeds below 32 and fails above, as it succeeds only below 30 or 29 depending on the number of previously created fields (number of digits in the field fid).
Comment #15
yched CreditAttribution: yched commentedWell, there's no need to test that field_name < 32 char works, the whole field.test demonstrates that ;-)
We just want to check that > 32 fails with a FieldException.
Comment #16
fgmHere it is with the test reinserted and commenting style fixed.
Comment #17
yched CreditAttribution: yched commentedThanks. Just fixed a couple minor points (missing trailing periods, trailing whitespaces) + grouped all failure checks at the bottom of testCreateField().
Other than that, RTBC.
Thanks !
Comment #18
yched CreditAttribution: yched commentedDries committed #17.
Back to active for the rest of the TODOs :-)
Comment #19
fgmTaken into account active/inactive field and instances.
Comment #20
fgmAdding Fields in Core tag.
Comment #21
yched CreditAttribution: yched commentedLooks fine by me. Thks fgm !
Comment #22
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Setting back to 'code needs work' for the remaining TODOs. Thanks fgm.
Comment #23
Dries CreditAttribution: Dries commentedComment #24
jcisio CreditAttribution: jcisio commentedWe have a TODO at http://api.drupal.org/api/drupal/modules--field--modules--text--text.mod... (from http://drupal.stackexchange.com/questions/8829/how-to-change-the-length-...)
Comment #25
h3rj4n CreditAttribution: h3rj4n commentedTODO's find in the fields module:
The first one can be found on the function
function theme_field_multiple_value_form($variables) { ... }
on line 301. There TODO claims that the HTML part should be in a seperate HTML tpl. The HTML is as follows:I'm not shure if these lines should be in a seperate html tpl. Wouldn't it be a little bit overkill?
http://api.drupal.org/api/drupal/modules!field!field.form.inc/function/theme_field_multiple_value_form/7
Suggestion: Remove the TODO from description.
The second, third and fourth one can be found in
function field_create_instance($instance) { ... }
on line 454 with a notice:I couldn't find any issues regarding these TODO's.
http://api.drupal.org/api/drupal/modules!field!field.crud.inc/function/field_create_instance/7
Last one can be found in
_field_write_instance($instance, $update = FALSE) { ... }
on line 554.http://api.drupal.org/api/drupal/modules!field!field.crud.inc/function/_field_write_instance/7
Comment #26
yched CreditAttribution: yched commented@h3rj4n : yes, I think those @todos can be removed, actually.
Comment #27
h3rj4n CreditAttribution: h3rj4n commented@yched: All of them?