While working on #1727266: Lazy load plugin managers with dependency injection, I talked to EclipseGc and Crell a bunch, and I learned that it is preferred, when reasonable, to get the manager out of the DIC directly, and not use a wrapper function.
With this, I was able to kill off:
- views_get_plugin_definition()
- views_ui_get_wizard()
- views_ui_get_wizards()
As well as one of the two conditions in views_get_plugin_definitions(), which I know aspilicious never liked in the first place.
I also killed the usage of views_get_plugin when the $type was unknown, but I left all of the direct calls for now.
Those remaining:
12 'join'
6 'style'
4 'access'
3 'wizard'
3 'display'
3 'cache'
2 'row'
2 'pager'
2 'exposed_form'
1 'query'
1 'filter'
Comment | File | Size | Author |
---|---|---|---|
#82 | drupal-1783196-82.patch | 6.38 KB | dawehner |
#76 | vdc-1783196-76.patch | 6.38 KB | tim.plunkett |
#68 | durpal-1783196-68.patch | 28.79 KB | dawehner |
#56 | drupal-1783196-56.patch | 28.7 KB | dawehner |
#50 | drupal-1783196-50.patch | 29.12 KB | dawehner |
Comments
Comment #1
tim.plunkettComment #2
damiankloip CreditAttribution: damiankloip commentedYes, looks good. When I originally did the DI patch/branch I was getting these directly, with this type of thing in mind.
Comment #3
aspilicious CreditAttribution: aspilicious commentedviews-useDIC.patch queued for re-testing.
Comment #4
dawehnerThis seems to be not totally right ... it's the system specific implementation
Probably the docs have to be adjusted as well.
We have to find a way to be able to provide a wizard for each table automatically, as you can't add a new view without it. Maybe an addition for the plugin manager class?
Comment #5
tim.plunkettThat code implied that it just automatically allowed any table to be used as a base. That sounds crazy, why wouldn't it have to explicitly add an annotated plugin for itself, even if the class is empty?
Comment #6
tim.plunkett#5 is wrong, I misunderstood.
Comment #7
dawehnerComment #9
dawehnerThere was an issue with relying on a function which just existed on admin.inc, so i moved it to views.module. I think views_fetch_base_tables seems to be a generic helper method not tight to the admin interface.
Comment #11
dawehnerassign my myself for fixing.
Comment #12
dawehnerThere was some code changed lately, so here is a reroll.
Comment #13
dawehnerI had a talk with eclipse how to properly implement that.
The best solution was to
Comment #14
dawehnerHere is a first version of that, the listing shows the system table, but creating a new wizard doesn't work yet.
Comment #16
aspilicious CreditAttribution: aspilicious commentedApparantly this is a configEntityBase sort function now. So we can remove this.
Comment #17
dawehnerIt's not what it looks like: http://www.youtube.com/watch?v=npjOSLCR2hE :)
This is about views data, which is a pure array, not something related with config entities at all.
Rerolled the patch against recent changes. The fail of the test is still there, but i asked eclipseGc for some help.
It seems to be that annotations + derivatives doesn't work together that fine.
Comment #19
dawehnerRerolled against the latest changes and fixed the test, see attached interdiff.
Comment #20
tim.plunkettMissing interdiff/patch?
Comment #21
dawehnerI'm sorry
Comment #22
xjmAny reason not to just do drupal_container()->get() here?
Comment #23
dawehnerThanks for the review!
The reason for that is probably that you have possible multiple calls to this.
But you are right, actually it should get the plugin manager instead.
Comment #24
tim.plunkettIf possible, I'd like to wait on this until after the merge. It seriously conflicts with the reorganization of code needed to kill lib/Views and views_init().
Comment #25
dawehnerFirst version for core.
Comment #26
xjmComment #27
dawehner#25: core-1783196-25.patch queued for re-testing.
Comment #28
dawehner#25: core-1783196-25.patch queued for re-testing.
Comment #30
dawehner#25: core-1783196-25.patch queued for re-testing.
Comment #32
dawehnerJust a rerole.
Comment #34
dawehnerI'm really wondering why i uploaded the wrong patch :(
Comment #36
dawehner#34: drupal-1783196-35.patch queued for re-testing.
Comment #38
dawehnerRemoved views_get_plugin_definition but the test failure is still reproducable. The problem is that for some reason
the TestFieldWidgetMultiple file get's scanned, even the plugin is disabled.
Comment #40
dawehnerRerolled, let's see how many patches are now failing.
Comment #41
damiankloip CreditAttribution: damiankloip commentedThis looks good, maybe the patch is slightly bigger than the title suggests though :) Oh well...
Do we need the class here? Shouldn't we just need the plugin ID?
Comment #42
dawehnerSo on a normal plugin you have the annotation discovery which sets the class.
If you have derivates you end up generating the class definition from getDerivativeDefinitions() which does
not have the class at that point. Sadly there is currently no base table in core which does not have a separated wizard
so you will not realize that.
Comment #44
damiankloip CreditAttribution: damiankloip commented#42: drupal-1783196-40.patch queued for re-testing.
Comment #46
webflo CreditAttribution: webflo commented#42: drupal-1783196-40.patch queued for re-testing.
Comment #48
dawehner#42: drupal-1783196-40.patch queued for re-testing.
Comment #50
dawehnerThis has been the reason why it didn't worked.
Comment #52
dawehner#50: drupal-1783196-50.patch queued for re-testing.
Comment #54
dawehner#50: drupal-1783196-50.patch queued for re-testing.
Comment #56
dawehnerA rerole against current core.
Comment #58
dawehnerOnce #1836204: Test failure in Drupal\system\Tests\Menu\BreadcrumbTest is in, this should pass.
Comment #59
tim.plunkettApparently that fix is now in #347988: Move $user->data into own table.
Comment #60
neclimdulSorry for the noise but changing title because components don't show up on the dashboard and I always forget what this issue is about.
Comment #61
moshe weitzman CreditAttribution: moshe weitzman commentedSince #347988: Move $user->data into own table is not going in smoothly, I think we should copy our dependency into this patch or break out the dependency from the user->data patch.
Comment #62
tim.plunkettI've reopened #1836204: Test failure in Drupal\system\Tests\Menu\BreadcrumbTest
Comment #63
dawehner#56: drupal-1783196-56.patch queued for re-testing.
Comment #65
xjmSo I talked to @dawehner about this issue (I had no idea why it would be blocking #1821844: Aggregator views integration) and apparently this patch also includes changes that are necessary to allow new base tables to be added without having to declare their own custom wizards. (?) Tagging for a summary. Can we clarify the situation, and either re-scope the issue or split it into two patches?
Comment #66
dawehner#56: drupal-1783196-56.patch queued for re-testing.
Comment #68
dawehnerRerolled the patch against latest HEAD.
Comment #69
tim.plunkett#68: durpal-1783196-68.patch queued for re-testing.
Comment #70
tim.plunkettAssuming this still applies, it's RTBC.
Comment #71
damiankloip CreditAttribution: damiankloip commentedYep, this looks good and has done for ages :) can we please get this in!
Comment #72
xjmI'd suggest updating the title and summary to explain the patch.
Comment #73
webchickYeah, that would've been nice. Had NO idea what this patch was about, but luckily Tim was online at Stupid O'Clock, and walked me through. Also I'm not sure how this patch is "major"... seems like pretty straight-forward refactoring.
Committed and pushed to 8.x. Here's the gist of my review, including one "normal" follow-up task.
The first thing I noticed was that these are a bit inconsistent, in that in most entity type and wizard_id match but in others they don't. Basically this is for disambiguation; in the case of something like "node" it exposes two different forms of its data, so "node" vs. "node_revision" allows for different settings.
I generally really dislike this business of dropping wrapper functions which are discoverable, and show up in my IDE, are findable on api.drupal.org, etc. in favour of making developers call directly into the guts of the magical mystery meat object that is drupal_container(). OTOH, I can't argue that this isn't consistent with what we do elsewhere, so is not a reason to hold up the patch.
There wasn't really enough in here for me to get a sense of what's going on without Tim's help, but I think that's more to do with my unfamiliarity with Views than a specific docs problem here. This looks pretty standard with other plugin patches I've committed.
For the curious, though, what is essentially being done in this patch is we're swapping out the custom Views plugin management stuff for this with the more standard one provided by core.
Also, if you're curious what one of these wizardy things looks like, check core/modules/node/lib/Drupal/node/Plugin/views/wizard/Node.php. You won't figure it out from the patch because it's not touching the "consumer" parts (which is nice, that the API for wizards doesn't really change).
This was the one spot where I definitely raised an eyebrow, since a class called "Standard" doesn't make any sense, and violates coding standards. However, I was informed by Tim that other areas in Views (arguments, filters, etc.) also do this "Standard.php" class name. So for now, I think it makes sense to keep this consistent, but let's get a follow-up filed to make Views conform to the OO naming guidelines.
Thanks, Tim!
Comment #74
xjm@webchick, the patch was major because it blocks the
hook_views_data()
integrations somehow for stuff that didn't already have a wizard. Or something. That's part of what I kept begging people to explain in the issue.That's not so much a followup issue as a followup release cycle phase, and on our roadmap. :)
Comment #75
yched CreditAttribution: yched commentedThe patch removes a lot of calls to views_get_plugin(), but doesn't remove the function itself, is that intended ? (just wondering)
Comment #76
tim.plunkettI guess we missed the last couple!
Comment #77
webchickComment #79
tim.plunkett#76: vdc-1783196-76.patch queued for re-testing.
Comment #81
dawehnerOh, good point, and we could also maybe convert views_get_plugin_definition?
The code itself
He we could reuse the container but i agree this would make it more difficult if we get either the plugin managers or the container injected.
I did a fast grep and there hasn't been any other kind of usage of this function anymore, so beside of the testbot failure and the previous comment.
Comment #82
dawehnerReupload the patch.
Comment #83
Crell CreditAttribution: Crell commentedWe really ought to be injecting the actual dependencies, but this at least eliminates the custom wrapper and Tim and Daniel tell me that injecting actual dependencies is a later step. So, +1 on small cleanups.
Comment #84
yched CreditAttribution: yched commentedInjecting dependencies will be an interesting exercise.
- For instance, 1st hunks in the patch are methods in DisplayPluginBase. How would we inject something from the DIC into a plugin instance ? Especially if each plugin class doesn't need the same DIC entries ?
- How would we inject something from the DIC into a ConfigEntity object ?
(having similar cases with Field API plugin managers being read directly from the drupal_container(), in places where I'm not sure how injection could take place)
Comment #85
dawehnerSo what views does is to have a configEntity and a runtime object (viewExecutable) which uses the information stored on the configEntity to instanciate all the plugins and then inject itself into all this plugins, so you end up with $this->view on all views plugins. So the outside world actually never talks directly with the configEntity but just the executable.
After some thinking it seems to be that injecting the dependencies might be helpful, though we will always have to add the container as well (as long we agree we always want to avoid drupal_container()), because you never know which services are used for which subplugin (which might come from contrib).
Comment #86
yched CreditAttribution: yched commentedI'm wondering whether we could have a ContainerAwarePluginFactory, with a way for plugin classes to tell it which DIC entries they need.
Would mean a static method, or more entries in the annotations.
OK, sorry for polluting this issue - #82 is RTBC still :-)
Comment #87
yched CreditAttribution: yched commentedShameless plug: regarding #83-#86 - opened #1863816: Allow plugins to have services injected
@Crell, your feedback would be much appreciated over there :-)
Comment #88
catchLooks fine as an interim step. Committed/pushed to 8.x.