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.
Apparantly it is impossible to define a "Drupal\list" namespace without getting php errors. This because list is a preserved word.
So the only option is to rename the list module to something else.
See #1591852: Convert field tests to PSR-0 for more info.
In this test patch I used "lists". We also need to provide an upgrade path but I have no idea how to handle that.
Comment | File | Size | Author |
---|---|---|---|
#82 | list.choice.82.patch | 36.16 KB | sun |
#73 | drupal8.list-options.73.patch | 65.96 KB | sun |
#69 | drupal8.list-options.69.patch | 65.72 KB | sun |
#69 | interdiff.txt | 1.93 KB | sun |
#67 | interdiff.txt | 666 bytes | tim.plunkett |
Comments
Comment #2
catchOuch.
I can't find the issue, but somewhere there's an issue to rename locale module, which is going to run into the same upgrade path issue as this one.
Comment #3
Berdirlists makes sense to me.
That's basically just a db_update that renames list to lists I think, also the filename.
The problem is that updates from list(s).module will only be detected after this, which means you'll need to re-run update.php. Will also need a dependency on this one. Maybe we can do it in the update_to_d8 function that's run extremely early?
Also, I guess most tests just failed because the module name needs to updated in setUp().
Comment #4
tstoecklerSince we usually don't do plurals (I can see why this would be an exception), what about listing.module?
Comment #5
webchickCould more information be provided as to why Drupal\list is running into problems? What other words are we likely to hit this with?
Comment #6
Berdirhttp://www.php.net/manual/en/reserved.keywords.php
list is reserved because of the list($a,$b,$c) = $array stuff.
Edit: So at least print.module and echo.module are other candidates that will run into this.
Comment #7
BerdirAnother way to solve this would be to introduce the discussed namespace=something to .info files because then list.module could define it's namespace as list_module or something like that.
Comment #8
catchI'd prefer not to rely on the namespace thing in .info for this, that was discussed for registering extra/custom namespaces, not to replace the main one, and I'm still not comfortable with the idea in general.
Comment #9
aspilicious CreditAttribution: aspilicious commentedI just tried to regsiter the "echo" or "print" namespace and indeed they are having troubles. :(
Comment #10
tstoecklerWe should document that starting D8 you shouldn't name a module like a reserved word. If you don't have any classes that would still be possible, but since that will be the edge case in D8 I assume, I think we should generally warn about that.
Comment #13
chx CreditAttribution: chx commentedThis is a rather unfortunate architecture limitation of PSR-0. I have two major concerns here: a rename like this, with the current update system is going to be painful. I recommend putting the update in field.install... also, the print module maintainers will be very happy too.
Comment #14
aspilicious CreditAttribution: aspilicious commentedchx this isn't a architecture limitation of psr-0. It's an architrecture limitation of namespace in php. I don't know why you think this has something to do with PSR-0?
When all the other psr-0 conversion issues are in this is the only blocker to remove the registry. So I'm going to move this to critical at that moment.
I do see another dirty hack around this problem. And thats a mapper for affected modules. For example we could map the "list" module to the "lists" or "listings". As there is only a small list of preserved keywords we could hardcode this. BUT again thats not a nice solution. We need some upgrade experts here ;)
Comment #15
tstoecklerIn hope of getting this issue a little bit more back on track, I still like listing.module. What do you guys think?
Comment #16
webchickAlmost all of the other PSR-0 patches are now committed, so this is quickly becoming a blocker.
I will see if I can lead a bikeshed session here at the #d8mi #drupaldevdays sprint to put this sucker away.
Comment #17
RobLoachIf #1591852: Convert field tests to PSR-0 was in first, this patch would be much easier.
Comment #18
webchickDone. :)
Comment #19
webchickBtw, just to explain a bit more about what this module does:
So in this context, I don't think "listing.module" makes much sense. I would expect "listing.module" to basically be Views. :)
It's actually kinda more like keyvalue.module, but I would expect that to be a key/value storage.
Naming is hard. :P
Comment #20
RobLoach"field_list"? Since it's adding list capabilities to field module?
Comment #21
webchickEh. I thought about that, but we don't call it "field_image", "field_file", etc. so this would be inconsistent.
Comment #22
webchickSame, btw, with 'lists' which otherwise would be a no-brainer replacement. We might want to do 'lists' anyway, however. :P
Comment #23
RobLoachWhen has Drupal been consistent? :P "lists" sounds like fun to me. The namespace seems open.
... We could rename them all to "field_*" to help make Drupal consistent. Supporting the upgrade path via field module, like chx suggested, shouldn't be difficult.
Comment #24
webchickOk, I'm going to recommend we go with 'lists.'
Marking RTBC to get some more eyeballs on this.
Comment #25
RobLoachDamZ suggested listfield (note the field suffix). I'm happy either either one. It really doesn't matter what the name is, as long as it's not "list"... In the mean time, we'll still need a patch here, and have Views to consider.
Comment #26
chx CreditAttribution: chx commentedOh. Listfield. If anything then that. Much better than lists.
Comment #27
jhodgdonReally what this module does is fields that give you options (selects, radios, checkboxes, listboxes). I have always thought that "List" module is confusing in the context of fields -- I don't think of them as lists at all. If you need to change the name of the module, I would vote for Options if that is an ... option. :)
Comment #28
tim.plunkettWell, options.module already exists. But I long wondered why list and option weren't one and the same. List provides no widgets of its own, and option provides no field types. Why not merge them?
Comment #29
webchickActually that's a very good question, and would not only solve the problem but would eliminate a weird UX confusion of having two modules that are very similar.
Maybe ping yched/KarenS, or git blame?
Comment #30
tim.plunkettWell, they were added in #361683: Field API initial patch as separate modules, so no help there.
AFAIK, the D6 equivalents of list_integer and list_float were in the number.module and list_text was in text.module (I think the functionality of list_boolean was just the default for optionwidgets).
So it seems that all of the allowed_values multi-select-ish widgets from various modules were abstracted into one list.module. But the leap to simply combining it with options module never happened.
Comment #31
catchMerging with options sounds good in and of itself, I'd completely forgotten they were different modules..
Comment #32
webchickOk, let's change the proposal to this then.
The only reason I can think that these are two different modules is because option widgets can be used on other fields than just list fields.
Comment #33
chx CreditAttribution: chx commentedIs there anything stopping us from changing options module without changing the field type name? Ie. provide list_boolean field type. This is not a user exposed thing.
Comment #34
webchickTo be technically proper, yes, we should namespace the fields by the module name.
However, in order to unblock this major I personally would be comfortable moving them over as-is and handling renaming + upgrade path as a "normal" follow-up task.
Comment #35
aspilicious CreditAttribution: aspilicious commentedThis only blocks the registry but that isn't going to go away for a few months. So I would prefer to fix this properly at once.
Comment #36
tim.plunkettHere's an initial untested attempt to merge the two.
I didn't attempt to rename the field types, as webchick suggested, nor did I PSR-0-ify the tests. Just a straight move.
Comment #38
tim.plunkettWhoops, I forgot about the entry in standard.info.
This installed locally for me.
Comment #40
tim.plunkettOkay, got the tests running. Still a couple failure/exceptions, they didn't really make sense to me right away.
Comment #42
aspilicious CreditAttribution: aspilicious commentedOne is easy. In the field_ui AlterTest.php
list_text should be different I guess :)
Comment #43
tim.plunkett@aspilicious I don't think that's what's causing the failures.
I haven't tried to change the names of any of the field types, since that would mean a full upgrade path, and ideally this will require only a minor switch of the field type's module.
One more attempt.
Comment #45
tim.plunkettOh, missed one instance of 'list' in a setUp. That's what caused the error aspilicious mentioned.
Comment #46
chx CreditAttribution: chx commentedThe ingenuity of our community to solve the insurmountable looking problems with ease again amazes me. Hats off to jhodgdon and tim.plunkett for coming up with the options merge.
Comment #48
tim.plunkettThe exceptions are all due to
$field['settings']['allowed_values']
being a string, haven't really looked at the rest of the failures (down to 7!).Taking a break for now, but I'll be back if no one else finishes it first.
Comment #49
BerdirThis should pass, two small changes:
- value callback on the on/off form fields wasn't renamed, that caused weird allowed values thing.
- The dynamic values test assigned the values to a non-existing field.
I've seen other field_list and similar names in there, we might want to change them as well.
Comment #50
aspilicious CreditAttribution: aspilicious commentedOk awesome! Now we can cleanup this and convert the classes to psr-0.
Do we have upgrade tests for this?
Comment #51
tim.plunkettWe'll need upgrade tests when switching over the field types. Nothing we've done so far needs an upgrade test.
Here's the PSR-0 versions. I think this should go in as is, and there can be a non-major follow-up to migrate the field type names.
Also, somehow this magically worked out to be the exact same number of lines added and removed, even with the PSR-0 stuff. Kinda cool!
Comment #53
BerdirIs the list.module entry in the system table removed automatically if it doesn't exist anymore? If not then I guess that's something that we need to do in an update function, I guess in options.install.. ?
Comment #56
tim.plunkettWe can add that in if need be, I'm not sure that we need it.
Comment #57
aspilicious CreditAttribution: aspilicious commentedWe are in the same namespace now!
OptionsFieldUiTest (although I know how you hate that :s :( srry)
10 days to next Drupal core point release.
Comment #58
aspilicious CreditAttribution: aspilicious commentedComment #59
Tor Arne Thune CreditAttribution: Tor Arne Thune commentedNo need for use statements for FieldTestBase and FieldException (if I didn't miss something).
Should be (...) OptionsSelectDynamicValuesTest
Not needed because we're in same namespace.
Comment #60
tim.plunkettWell #1627350: Patch for: Case of acronyms in class names (SomethingXSSClassName versus SomethingXssClassName) hasn't been decided yet, so I'm not changing this to "Ui" until it is. ;)
Fixed the rest, thanks!
Comment #61
Tor Arne Thune CreditAttribution: Tor Arne Thune commentedThanks :) Found one outstanding issue.
Definition of... OptionsDynamicValuesTest -> OptionsDynamicValuesValidationTest.
Comment #62
yched CreditAttribution: yched commentedSorry for coming late to the party, I'm on the road and semi-afk for the time being.
The list/options modules split comes from the CCK era.
The 'list' field types were just options within the number and text field types ("restrict to a given list of alowed values"). This "allowed values" feature was more of an afterthought added on top of the original text/number field types back in the early CCK days (D4.7 ? D5 ?), but didn't integrate very well conceptually. At some point during the D7 Field API overhaul, it was decided that this behavior was specific enough (+ required specific logic, and lead to inconsistent combinations - a "formatted" text field with a "list of available values" ??) to be moved to dedicated field types - "list" field types.
Options.module only provides generic (field-type agnostic) widgets, free for any field type that see fit to use them : in D6, text & number (only relevant if they had "allowed values"), node/user reference... In D7, taxonomy fields use options widgets too (and taxonomy.module requires options.module).
That split still makes sense IMO. There is no real reason that, in order to get select widgets for your taxonomy fields you need to enable the "text/number list" field types - especially if this move is motivated by "mundane" namespaces / reserved keywords issues...
This being said, I don't really have a better suggestion for the namespace / keyword issue right now. And I agree that "options.module" is currently a little hard to identify for end users, since its only visible effect is to enable a couple widgets for a couple field types - which is not a common pattern in core. Pure widget modules are more frequent in contrib, but they usually target a specific field type (file, taxonomy...).
OTOH, in the proposed approach, the main visible effect of options.module would be to enable list field types. It's not going to be much clearer that it also enables widgets for, say, taxonomy or reference fields.
Comment #63
tim.plunkettJust a note, they're both currently part of the standard install, so to the majority of users it will not matter that one goes away.
Comment #64
jhodgdonIf we do want them to be two separate modules... The thing is, "List" still makes zero sense to me as the human-readable module name. Really it's a module that allows you to define the static allowed values for an options widget, and "List" just doesn't get the point across.
So if we do want them to be separate (i.e., if the baggage of allowing for sets of static values if you enable the options widgets is too much), then I would vote for a name more like:
- Static Allowed Field Values [loooonnnnggg name, but gets the point across of what it does]
- Allowed Value Sets (or Allowed Value Lists? I guess technically they are lists in the sense that they have an order, rather than sets)
- Allowed Values for Options
- Option Values [this one would be my favorite -- then it kind of gets across the point that it's for use with the Options module?]
Thoughts?
Comment #65
RobLoach#60: drupal-1592632-60.patch queued for re-testing.
Comment #66
RobLoachOptionsDynamicValuesTest -> OptionsDynamicValuesValidationTest
Comment #67
tim.plunkettThe diffstats and patch sizes are drastically different from here to #60, but I confirmed that Rob and I just have different versions of git, and they handle renames differently.
Here's the interdiff as proof. (note the size!)
Comment #68
tim.plunkettI'd much rather just merge them (patch above!) but if that's not an OPTION I vote for "Option Values".
How do we gather consensus and move forward here?
Comment #69
sunFWIW: The reason why @Rob Loach's patch is larger is because the diff was generated with a too low minimum similarity for the rename detection. git's default value is around 50%. His patch shows renames based on similarities of ~10%. A more sensible minimum value to use is 25-30%. (The value can be specified along with option; e.g.:
git diff -M30%
)I was unhappy with the location of the moved code from List module. Typically, I expect field modules to define their Field API integration functions in a sensible order; i.e., field (type) info, field settings, field CRUD hooks, field widget, field formatter. As a coder who is not using any IDE, I really appreciate it when code is structured and grouped cleanly. I therefore adjusted the patch.
While doing so, I realized that some of the field settings form #element_validate and #value_callback helper functions are using names that do not really make clear that they belong to the field settings form. I adjusted their names.
Without the latter, I wouldn't have provided an interdiff, because the functions are just moved around. So to clarify the latter, I'm attaching the interdiff for those renames, before I moved the code.
Aside from that, this looks RTBC to me.
Comment #70
tim.plunkettAh yes, I'm definitely on board with more sane organizations of functions. I didn't put any thought/time into that.
Those function renames look good.
Comment #71
RobLoachLooks RTBC to me too! Is anything missing in this patch?
Comment #72
sunThe only remaining blocker for this patch is the Field API maintainer's objection ;-)
@yched: Thanks for providing insight and feedback! :)
Comment #73
sunIn retrospective, nothing in #72 seems to be a total show-blocker.
However, there's a real bug in this patch: Options module cannot perform the update from List to Options module, because Options module might not be enabled at all.
Fixed in attached patch; by moving the update from options.install into field.install.
Comment #74
sunBetter title. Can we move forward here? This is the last blocker for removing the registry, and I think this is RTBC.
@yched raised some general concerns in #62, which I think have been addressed in #72:
tl;dr: The allowed values functionality should be abstracted/plugin-ified when that is possible, but otherwise, this merger does not introduce architectural problems. "Options" was and is a poor name, but improving that is out of scope for this issue.
Comment #75
KarenS CreditAttribution: KarenS commentedEchoing what yched said, the reason for the list module was basically to provide a vehicle for allowed values lists. It was separated out because the original architecture munged together bare-bones text and number fields with the whole concept of lists of values. I think the reason for pulling that out makes sense. I'm not sure that we have any reason for an allowed values API outside of the list field. What else would use it besides the list field? The list module *is* the allowed values API.
Options was originally called Option Widgets, which made a lot more sense. But it got truncated somewhere along the line into the much less understandable name of 'options'. The idea there was that it might become a whole collection of ways that you could view multiple values. And those widgets could work on things besides 'list' fields, so it made sense for the module to stay separate.
However I guess the original concept has fallen apart somewhat. I suppose there is a valid case to combine them into a module that provides a field that can contain lists of values and a widget that can display lists and an API for creating allowed values lists. The original name of 'list' makes the most sense for this functionality. Dumping this all into an 'Options' namespace seems somewhat more confusing. So I don't object to the general idea, but I think the name choice is just going to create further confusion in the future. I'd go back to some variation of the word 'list' because that is far more clear than 'options', IMO. Something like 'option_list', or 'listing' or 'value_list' or maybe even 'allowed_values', since this basically is the API for allowed values lists.
Comment #76
KarenS CreditAttribution: KarenS commentedHowever I do agree that allowed values should be pluggable. I may have misunderstood that argument, I read this to say there was a proposal to create a separate allowed values API somewhere else, but reading back I may have misunderstood.
Comment #77
tim.plunkettBetween #72 and #75, I think there is consensus on combining the two modules.
I opened #1677052: Rename the Options module (which contains the former List module as well) as a follow-up to rename it.
Tentatively marking RTBC.
Comment #78
tstoecklerI do agree with @sun's assessment, but this could still use a sign-off from yched, IMO. I guess we can leave it at RTBC, but maybe one of the issue queue overlords can assign it to him.
Comment #79
chx CreditAttribution: chx commentedNo overlords necessary any core maintainer can.
Comment #80
xjmAssigning to yched based on the above and @tim.plunkett's request.
Comment #81
tstoeckler@chx: That's what I meant. If I sounded negative or condescending that wasn't my intention, sorry. Not a native speaker.
Comment #82
sunAFAIK, @yched pretty much went for AWOL this year/summer, so I'm not sure whether it's the best idea to defer/delegate to him, as it could easily take some weeks until he comes back from rocking the stages of this world. :)
I'm also not sure whether @KarenS' feedback was really 100% in line with what we're proposing to do here. In an attempt to read between the lines, I've the slight impression that the comment might also meant to say:
:-D In other words, I do not really have the impression that Field API maintainers are fully on board with this change proposal.
What are allowed values?
An allowed value is a value of a selected list of valid values; a selection.
Alternatives for: "selection"
So let me present you this alternative. :)
6073f06 Renamed List module files to Choice module.
0326104 Renamed "list" to "choice" (where appropriate; i.e., not for list of allowed values).
e0dceb1 Changed dependency in Standard profile.
8d7ee18 Fixed OptionsSelectDynamicValuesTest.
Comment #84
KarenS CreditAttribution: KarenS commentedThe idea of merging 'List' and 'Options' into a module that is designed to handle everything around the process of creating a list of allowable values and displaying it is acceptable to me. I was somewhat confused about the discussion about an Allowed Values API. I agree allowed values really ought to be pluggable, but if the proposal was to move a 'allowed values' API somewhere else I disagree because that is the fundamental purpose of the List module in a nutshell.
The current patch is merging them into the Options module, and I don't like that name for the new combined functionality, but there is now another issue about fixing the name.
The thing lost with this direction is the ability to use an option list widget without enabling the whole list field/allowed values functionality. But it's probably likely that most of the core field modules will be enabled most or all of the time anyway. So maybe that's an acceptable loss. The main place that comes up now is with reference fields (node or entity reference). If one of them is added to core the reason for the current architecture might seem more reasonable.
So with that all said, I think the patch in #73 is an acceptable direction -- combine the modules and then fix the name in another issue. I can't speak for yched of course :)
Comment #85
sunAlright. I (still) agree, and I think that is logical and makes sense.
In case "Choice" is a much better name, then we can still rename Options to Choice in #1677052: Rename the Options module (which contains the former List module as well) -- the order of renames makes no difference at all.
Comment #86
catchOK committed/pushed this to 8.x. I think we might want to rename options module but let's discuss that in the other issue. I don't have a particular problem with merging the functionality - if and when we have an entity reference module in core that's not remotely using the 'list' stuff we could always revisit that too.
Comment #87
sunComment #88
eddie_c CreditAttribution: eddie_c commentedAdding change record
Comment #89
Dave Reid@eddie_c: It looks like the change record for this issue also includes the changes from #1677052: Rename the Options module (which contains the former List module as well) which haven't been committed yet? Also, it would help if you could provide a link to the change record you've created.
Comment #90
ZenDoodles CreditAttribution: ZenDoodles commented@eddie_c Thanks for your help on this, but unless I misunderstand, the patch in #82 was not the one Catch committed, but the one in #72 which merges the list module into the options module.
Should we also mention that going forward, folks shouldn't name a module with the same name as a reserved word?
Comment #91
tim.plunkettAlright, I've updated http://drupal.org/node/1691614
Comment #92
aspilicious CreditAttribution: aspilicious commentedLooks good now :)
Comment #93
tim.plunkettComment #94
KarenS CreditAttribution: KarenS commentedWe need an update hook here -- any field that was created prior to this change in D7 is going to have 'list' as the module name in the field_config table. This won't be an issue until people start upgrading, but it needs to be addressed.
I'm creating a follow-up issue for this, #1697408: Update module name in field/instance config for List fields
Comment #96
effulgentsia CreditAttribution: effulgentsia commentedI think I stumbled on some orphaned code from this issue, and opened a followup to remove it: #2012130: Regression: Views integration for "list" field types is broken. If anyone here has insight on whether it's safe to remove that code, or if we need to replace it with something, please comment on that issue. Thanks.
Comment #97
PanchoFollowup: #2020691: Misleading module description for Options