Problem/Motivation
Views currently has a concept of handlers, which controls how a certain part of a sql table is accessed in a view. So each sql table field
has a handler which takes care about the behaviour. In the actual view config currently views just stores the $table.$field and then work out the used handler (which is a Durpal 8 plugin) out of the hook_views_data. Sadly the proposed metadata config needs to have a plugin_id to be able to load it's submetadata. Another issue on which we need this is a reworked version of broken handlers. With the plugin_id as part of the config we can tell the user which plugin is missing.
Proposed resolution
Save the plugin_id as well on the config and alter all existing views data to contain this information.
The name export would look similar to that:
display:
default:
fields:
title:
id: title
table: node
field: title
plugin_id: node_title
module: node (this would be added in the other issue)
| Comment | File | Size | Author |
|---|---|---|---|
| #47 | drupal-1810480-47.patch | 71.67 KB | dawehner |
| #47 | interdiff.txt | 4.63 KB | dawehner |
| #43 | interdiff.txt | 675 bytes | dawehner |
| #43 | drupal-1810480-43.patch | 74.84 KB | dawehner |
| #39 | drupal-1810480-39.patch | 75.5 KB | dawehner |
Comments
Comment #1
dawehnerThis patch is required to have a proper translation support for views.
Started to write a patch to convert all existing views config files
Comment #2
dawehnerCurrently the script needs to support other handler types then fields.
This patch runned the previous script and changed all of the test patches by hand, because the views data for the tests is dynamic so you can't call views_fetch_data on that.
Comment #4
xjmComment #5
dawehnerDid some work on that, now it fixes already a lot of the yml files.
Sadly the script doesn't work in all situations yet, so you still have to change a lot of places manually.
Comment #6
dawehnerFor sanity here is a patch which just shows the php changes.
To be able to compare arrays really easy i added a helper assertion for that, which also gives you the diff
if something is not equal. Maybe this could be moved into the main assertions?
Comment #7
dawehnerPS: This interdiff is coming from another issue.
Comment #8
yesct commentedadding tag for d8mi since in #1 @dawehner says
Comment #9
dawehnerUpdated the new views config files as well, so basically a rerole.
Comment #11
yesct commented#9: drupal-1810480-9.patch queued for re-testing.
Comment #12
ACF commentedTrying a re-roll.
Comment #13
dawehnerAnother reroll against some other recent changes.
Comment #14
xjmBut #1648930: Introduce configuration schema and use for translation :(Totally thinking of a different issue. Proceed.Comment #14.0
xjmupdate
Comment #15
damiankloip commentedYeah, I was going to say... :)
This patch looks good to me, there are a couple of places that are wrapping '' around strings. Do we need to do this? generally in yaml you don't need to for single word blocks. Do we have a standard? or are those the only ones left unchanged?
Comment #16
dawehnerYeah the plugin is called 'null' so there is no way around that. One odd thing was nid: but i guess the casting took care about that.
Comment #17
damiankloip commentedFair enough, I like this in that case.
Comment #18
xjmShould be
format_string()rather thant().For the sake of reviewers, here's the actual change.
I think removing these is out of scope? Can we file a separate issue to kill them if appropriate?
Comment #19
dawehnerYeah regarding the actual php nothing changed since #6.
OK.
Fixed the assertion message.
Comment #20
dawehnerHere is the cleanup: #1867390: Remove unused test yml files
Comment #21
catchThis might be useful for other things, could put directly in Simpletest maybe?
How was the plugin ID found before? Doesn't look this this patch removes that code?
Comment #22
dawehnerWhat about moving this function to the top in a follow up?
So before the patch the data for handlers looks like that:
then views uses that information && $data = hook_views_data() and get the id out of $data[$table][$field]['field']['id']. This is currently not yet affected by this patch, to make it as simple as possible.
Comment #23
catchhmm OK, is there a follow-up for the hook_views_data() bit?
Comment #24
dawehnerTo be honest i don't think this will be useful, because we need the metadata attached in hook_views_data anyway to initialize a handler.
Comment #25
catchOK one more question then.
Something like
+ plugin_id: node_created_monthIf a module changes hook_views_data() and their views plugin to a different name, then currently can an existing view survive this since that's inferred rather than explicity? With the patch wouldn't every view need to be updated to point to the new plugin name?
Comment #26
dawehnerYeah you are totally right about that, but this is a general problem who ones a certain piece of configuration. For normal plugins like a style plugin this is already the case,
so i guess we will have to come up with an easy way to either load and save all views or manually update them?
Comment #27
xjmThe Views tests also have a method like that for objects IIRC.
Comment #28
dawehnerOpened a follow up for the assertion message: #1870786: Add an assertArrayEqual method to compare two arrays
Comment #29
xjmRegarding changing a plugin ID: IMO, if a module changes its data tables or plugin IDs or whatever, it's that module's responsibility to provide an upgrade path with that. I think it'd be a matter of loading all saved views, checking them for the old plugin, and then updating them and re-saving. Pretty simple. However, we could either provide API for it or document how to do it. Loosely related issues:
I filed a specific followup to discuss this further: #1874394: Provide an API for upgrading configuration
Comment #30
webchickOk sounds like the follow-ups in #29 should address catch's concerns. If I'm wrong, please feel free to roll this back.
Committed and pushed to 8.x. Thanks!
Comment #31
webchickNevermind. :P This broke HEAD because it references the non-existent views_fetch_data() function.
Reverted.
Comment #32
dawehnerI'm sorry for breaking core, so we should really retest our RTBC issues more often.
Comment #33
dawehnerAnyone up for a RTBC again?
Comment #34
damiankloip commentedYep, happy with this now, as it uses our shiny new views_data service and not views_fetch_data.
Comment #35
catch#32: drupal-1810480-32.patch queued for re-testing.
Comment #37
dawehnerLet's update all the changes yml files in the meantime.
This patch is a damn nighmare.
Comment #39
dawehnerPlease review that, as it's a pain to rerole.
Comment #40
dawehner.
Comment #41
damiankloip commentedThis might not be allowed, but I don't mind. Having an issue just for that seems overkill.
Same, here, but still ok :)
I think this one IS a mistake?
Awesome
We might not want to bother removing this if we want #1825896: Add module owner to plugin data on handlers in?
Otherwise, let's please try and get this in asap!
Comment #43
dawehnerYeah this @todo is a long outstanding one.
Regarding the ':': It seems to be that the yml parser might ignore that?
Comment #44
sunIs "standard" really a plugin ID...? (?)
null?
I guess you meant "ignoring the array keys"?
assertEqual()ignores the order already.Comment #46
damiankloip commentedThe comment is fair enough I think, but I don't think we should be discussing actual plugin IDs in this issue. And yes, we have one called standard.. I know :)
Comment #47
dawehnerYes our default plugins are called standard, especially because you can't have a Default.php (sure I know that $file_name != $plugin_id).
Yes, we have a argument plugin, which does nothing with the query, aka. ignores the argument value.
Interesting comment regarding assertArrayEqual(), let's remove that from the patch as it's not needed.
Comment #48
tim.plunkett#47: drupal-1810480-47.patch queued for re-testing.
Comment #49
tim.plunkettRTBC if it still is green.
Comment #50
webchickCommitted and pushed to 8.x. Thanks!
Comment #51.0
(not verified) commentedupdate view export