Followup for #1764278: Run PluginManagerBase::processDefinition() in a ProcessDecorator :
Now that definitions are processed within the discovery, the factories can receive $this->factory instead of $this for their DiscoveryInterface $discovery param.

So far, plugin managers that relied on processDefinition() had to pass themselves ($this) instead of the discovery, since they were the only ones able to handle valid, "processed" definitions.
For plugin managers that didn't rely on processDefinition(), passing $this->discovery worked, so the current state of core is very inconsistent, and this confuses people implementing new plugin types, most of whom start by copy/pasting some existing core manager.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Status: Active » Needs review
FileSize
6.74 KB

Patch.

EclipseGc’s picture

The PluginManager still implements the interface for discovery, and can provide some essential work around techniques in various circumstances. I would heavily advise against doing this, having the ability to pass the plugin manager here and have an additional level of discovery handling that doesn't absolutely require another decorator is really essential in my opinion. I'd mark this won't fix, but am willing to at least have the discussion.

TL:DR

If you do this all custom processing will have to be a new decorator and that's sub optimal IMO.

Eclipse

tim.plunkett’s picture

We already have the ProcessDecorator, I think that covers the use case of a PluginManager wanting to do any custom processing.

This seems to me how things should work, and we just didn't do it this way due to hacks.

neclimdul’s picture

Status: Needs review » Closed (won't fix)

Better reason, the commit to that issue was a hack I said was ok till we had a real solution. Processing was not the only reason to do this, just the most visible and easiest to run into. Going to to close this.

neclimdul’s picture

Sorry for the x-post tim. Just to be clear, the interface exists on the manager so any amount of inlining or control can be shifted as needed by the manager. Honestly, how core uses that could be up for discussion but this is the expected behavior. Since these calls are internal to the manager it doesn't really matter but it sets a possibly confusing precedent in our core usage in what are our de facto examples and is a bit of a premature optimization with likely minimal if any gain. That's why I see this as something we shouldn't be looking to fix.

effulgentsia’s picture

Title: Pass the real Discovery objects to the Factories » Make all core plugin managers be consistent as to whether $this or $this->discovery is passed to the factory
Status: Closed (won't fix) » Active

While contrib should be able to pick which technique to use, it would be ideal for core to set a best practice. We currently have some plugin managers doing it one way and some the other, for no good reason.

I personally agree with neclimdul and prefer passing the manager itself, but I also understand the DX confusion of doing so, especially since in other parts of the plugin system, you pass $this->discovery. I don't know yet whether the solution to that is to make core pass $this->discovery, or to get to the bottom of why it's confusing to pass $this, and fix that point of confusion.

tim.plunkett’s picture

Status: Active » Needs review
FileSize
3.38 KB

Since FetcherManager was the first plugin manager, I remember trying to pass $this->discovery in Views and having it blow up due to the processing. So yeah, we should be consistent.

Let's see if anything here fails.

yched’s picture

Issue tags: -needs profiling

I'm sorry but this is backwards.

Existing plugin managers in core have no reason whatsoever to pass the plugin manager to the factory. Those that currently do all started out by passing $this->discovery and discovered it didn't work because of #1764278: Run PluginManagerBase::processDefinition() in a ProcessDecorator (plugin self inspection didn't work, $plugin->getDefinition() returned a non-processed definition). This is fixed now.

Are we preparing for the case where the discovery object might in fact not be able to be a trustworthy source of plugin definitions ? If so something sounds wrong to me. When it comes to accessing plugin definitions, the discovery object should be enough.

Then, if a specific plugin type has a case for the factory to receive the PluginManager as a whole, fine, it can do so, most preferably with an explicit comment stating why it needs to deviate from the standard pattern.
If a specific plugin type has a case for its plugin objects to be able to access methods from the PluginManager, fine, then those should hint for FooPluginManager in their construct, not DiscoveryInterface. And the plugin type can use a dedicated factory that receives and passes a FooPluginManager.

The patch in #1 is not about removing flexibility, it's about going the expected way when there's no need not do so. PluginManagerInterface implements DiscoveryInterface et al so that you *can* be more flexible if you need. It doesn't mean that core should use that trick for no reason on all its plugin types, and de facto have 99% of contrib replicate it.
"Yeah, the factory expect a discovery object but well, you shouldn't really give it your discovery" ? I don't really see myself explaining that when training people on the Plugin API.

Also, that might be minor, but passing $this when $this->discovery works is adding one function call for each access to a plugin definition.(which are already 3 function calls away even with a warm CacheDecorator). Again, with the TypedData API, that happens a *lot*. And while it might not be that bad for the other *current* core plugin types, we can't know about contrib.

tim.plunkett’s picture

Issue tags: +needs profiling

I did notice that the test run for this patch was extremely long. If the TypedData performance hit is true, this might be a problem.

effulgentsia’s picture

Issue tags: +needs profiling

#7: discovery-1851706-7.patch queued for re-testing.

effulgentsia’s picture

I did notice that the test run for this patch was extremely long.

Whoa! That first run was 81 mins. I asked for a retest to see if that was a fluke or really pointing to a serious slow down.

effulgentsia’s picture

"Yeah, the factory expect a discovery object but well, you shouldn't really give it your discovery" ? I don't really see myself explaining that when training people on the Plugin API.

FWIW, here's an allegory. Feel free to use it in training if you like it.

Once upon a time, there was a Santa Claus. He had two very important responsibilities. He maintained a list of who's naughty and who's nice. And on Christmas Day, he delivered presents. The world wasn't as populated as it is now, so he managed to do all that by himself.

As the world population grew, he couldn't keep up. So now, each city has its own Santa Claus. Every child has a mobile phone application for asking Santa whether they've been naughty or nice. And every parent has a mobile phone application for letting Santa know when the kids are asleep and that it's time to deliver the presents to their house. The applications know the city each phone is in, and therefore, which Santa Claus to send the request to. Neither the children nor the parents know how their Santa Claus maintains the list or delivers the presents, whether he does it by himself or has a staff. Not knowing is part of the fun of Christmas.

In one small town in Nebraska, the local Santa does it all himself.

In Los Angeles, the local Santa decides to hire a private investigator, Dick, to keep tabs on who's naughty and who's nice. He also hires an actor/stunt-man, Bob, to put on the suit and deliver the presents. When Santa gets pinged by a child requesting to know which list he's on, Santa calls Dick and asks. When he gets pinged by a parent that the house is ready for present delivery, he passes that on to Bob. But, Bob needs to know which children in the house have been naughty and which have been nice, so he can pick out the right present for them. When Santa sent Bob out on Christmas Eve, he gave him his phone number, so that Bob could call him when he needed that info. Santa had considered just giving Dick's phone number to Bob, but he decided against that, because he didn't quite trust Dick, and wanted to oversee the operation himself.

In New York, the local Santa is a no nonsense guy. He doesn't have time or patience to deal with shady characters, so he hires the police chief to make the naughty/nice list and the fire captain to make the deliveries, and he gives the police chief's direct line to the fire captain.

effulgentsia’s picture

Per the allegory in #12, I don't see there being a clear right or wrong answer here. Really, it's up to each plugin manager. But I do think consistency in core would be nice, and the argument in #8 to make core's default be the lowest overhead one, and for only plugin managers that need to intervene to do so, with a comment explaining why that intervention is needed, is pretty compelling.

EclipseGc’s picture

I'm actually not sure that I agree on consistency per se here. Obviously we should be as consistent as possible, but if we have special situations that warrant a different approach, then we should consider what that special situation entails. This is actually one of the benefits of the Plugin Manager implementing all the relevant interfaces.

Also, fwiw, the "fix" in #1764278: Run PluginManagerBase::processDefinition() in a ProcessDecorator is a hack around a problem we weren't sure how to solve... it was not in and of itself a solution. I think I do have a solution that I'll be attempting to provide code for shortly. We'll see where things go from there.

Eclipse

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett

The test suite takes 82 minutes with this patch. Two test runs in a row.

Out of curiosity, I'll post the opposite patch tomorrow.

yched’s picture

LOL at @effulgentsia's christmas carol. Epic piece of writing !
I'd object it's a bit long to explain one line of code in a training session though :-)
Also, my feeling is that pattern would still be a manager with one discovery, that internally delegates to several «local area» discovery objects.

Obviously we should be as consistent as possible, but if we have special situations that warrant a different approach, then we should consider what that special situation entails

Fully agreed, and the patch here does not remove any of that flexibility for those special cases. It just doesn't leverage it for the cases that are not special and that will get replicated in all of contrib for no reason. If we come to one of those special cases in one of core's plugin types, then +1 for ditching consistency there.

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned
FileSize
6.74 KB

Just to see what happens.

EclipseGc’s picture

Yes and my point was that the typical case should be passing the plugin manager itself, not discovery specifically.

Eclipse

tim.plunkett’s picture

I'm sending that back for retest, but it finished in 48 minutes. Compared to 82 minutes.

EclipseGc’s picture

Well, and to be clear, if we can say "wow that doubles the time for this one plugin type" then that seems a perfect example of when we'd special case it.

Eclipse

yched’s picture

re @EclipseGc #18:
So what you're saying is "we *might* have some special case, so let's make sure everyone treats their case as special even though we currently have none of those". I don't get this.

From #1811816-30: Benchmark node_page_default vs. node view, on a page with 10 views blocks:
650 calls to Drupal\views\Plugin\Type\PluginManager::processDefinition(), 5% of the page request
That was before ProcessDecorator, so that meant 650 accesses to plugin definitions. So passing the manager instead of the factory would just mean adding 650 wrapper function calls for no reason.
Add to that all the of stuff that have yet to move to the plugin API.

effulgentsia’s picture

So what you're saying is "we *might* have some special case, so let's make sure everyone treats their case as special

The word "special" is implying a perspective.

Perspective 1: $this->discovery is a protected object. Passing it to the outside world breaks encapsulation. Do so only to objects that you trust (e.g., consider the factory object a "friend" in C++ lingo), and only in the "special" situations that need it (e.g., for plugin types that are instantiated frequently enough that the performance improvement is non-trivial).

Perspective 2: Most plugin managers should delegate all discovery responsibility to $this->discovery. They shouldn't need to further manipulate the definitions returned by $this->discovery. Given that, pass the narrower object to the factory. Only pass the full manager to the factory in the "special" situations that need it (e.g., when there's a good reason for the plugin manager to mediate interaction between the factory and the discovery).

tim.plunkett’s picture

Most plugin managers should delegate all discovery responsibility to $this->discovery

Emphasis mine. I'm coming from perspective 2.

yched’s picture

Coming from perspective 2 as well.

Although I'm fine with perspective 1. What this is about is providing the protected $this->discovery to the factory, that will pass it along to instanciated plugin objects so that they can access their own definition when needed. The factory is a "friend", so are the instantiated plugins. The factory doesn't leak.

EclipseGc’s picture

Thanks effulgentsia, that was a great comment.

yched, I think eff nailed this, your "special" and mine are VERY different. I'm saying, that the plugin manager does certain handling that is universally beneficial. Any "special" case that needs to code around that (whatever the reason)... should code around that. We should not assume everyone understands all these aspects because we've already proven that everyone does not. The plugin manager simplifies much of this by making this fairly cookie cutter, we should use it as such. Passing $this->discovery will hurt us in the long run, and prevents any sort of plugin manager specific logic for definition lookups from ever firing, and instead forces the developer to rely 100% on new decorators. New decorators should provide the sort of universally applicable solutions we see in core, not plugin type specific code, and passing $this->discovery is going to force the issue on that.

We should not be passing $this->discovery except in "special" cases.

Eclipse

yched’s picture

I think see your point, but I can't agree with this :

Passing $this->discovery will hurt us in the long run, and prevents any sort of plugin manager specific logic for definition lookups from ever firing

It does not prevent any sort of plugin manager logic. *If* a specific plugin manager needs this specific logic (which none of the current core managers do), then it *can* totally pass $this instead of $this->discovery.
Plugin managers are isolated beasts. Passing $this->discovery in the managers for which this is good enough doesn't prevent anything for the other managers.
But passing $this instead of $this->discovery everywhere as a way to say "hey you can do it too it will let you do cool tricks" just adds a couple hundreds of runtime func calls for nothing - and that's on a bare core site without 50+ contrib modules adding their own plugin types.

I'd also argue that passing $this->factory is simpler conceptually.
Plugin API is designed around the idea that you have a plugin manager that uses a discovery and a factory. Great: simple, elegant, well separated.
In your plugin manager, you create a factory, you create a discovery; the factory needs a discovery, fine, pass it the one you just defined, why pass something else ?
- oh, because look, there's a trick, the plugin manager *itself* is a discovery, so you can pass it instead
- oh... ok - but why would I do that ?
- because, well you could need it, even though TBH there's 95% chances that you won't.

So, both simpler and more efficient ? I really don't see why we wouldn't go for that pattern in core, and let contrib use the fancy trick if it needs.

Well, I'm afraid we're running in circles, or talking past each other :-)

I think it boils down to: in such a low level, ubiquitous system as the Plugin API, I'm +1 on encouraging patterns for speed if it makes no functional difference for the implementations at hand - and for the plugin types in core, it makes no difference, they *do* work with $this->discovery, and few plugin types won't.
The way I see it, the "special" cases are the ones where the simple + efficient pattern is not enough. Few are. Let's document how they can be handled, but let's not use actual runtime core code for that.

effulgentsia’s picture

I have an idea that might break through the stalemate.

The original reason for wanting $this passed to the factory is so that PluginManagerBase::processDefinition() could be protected instead of public. We lost that in #1764278: Run PluginManagerBase::processDefinition() in a ProcessDecorator, because running processDefinition after CacheDecorator was problematic. So now we have this code in HEAD (using FormatterPluginManager as an example):

$this->discovery = new AnnotatedClassDiscovery('field', 'formatter');
$this->discovery = new FormatterLegacyDiscoveryDecorator($this->discovery);
$this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition'));
$this->discovery = new AlterDecorator($this->discovery, 'field_formatter_info');
$this->discovery = new CacheDecorator($this->discovery, 'field_formatter_types', 'field');
$this->factory = new FormatterFactory($this);

And are debating that last line. But, what if instead, we do this:

$this->discovery = new AnnotatedClassDiscovery('field', 'formatter');
$this->discovery = new FormatterLegacyDiscoveryDecorator($this->discovery);

// Look where we insert $this in the chain.
$full_discovery = new AlterDecorator($this, 'field_formatter_info');

$full_discovery = new CacheDecorator($full_discovery, 'field_formatter_types', 'field');
$this->factory = new FormatterFactory($full_discovery);

And then this allows us to remove the ProcessDecorator and make processDefinition() protected again, and also gives the factory direct access to the object with the cached definitions.

Everyone wins?

effulgentsia’s picture

Oh wait, that won't work as-is, because then the application code that calls $plugin_manager->getDefinitions() won't get the altered definitions. Dammit! But maybe there's some variation along these lines that could work?

effulgentsia’s picture

LOL. Apparently #27 is essentially the same idea as EclipseGc posted in #1853382: Remove ProcessDecorator in favor of a solution that is in line with the original intent., and I posted what I thought was my idea *after* having skimmed the patch over there, without even realizing I had subconsciously stolen his idea.

But he ran into the same problem there as in #28: there is no way to do this without enlarging either DiscoveryInterface or PluginManagerInterface, and that defeats the whole purpose.

EclipseGc’s picture

@effulgentsia

lol :-D

tstoeckler’s picture

I think #28 is precisely the reason I dislike passing $this around. I want $plugin_manager->getInstance() to act on the same information that I get from $plugin_manager->getDefinition(). In practice, there's really no difference, but conceptually it's a WTF to me, if that's not the case.

The Factory get's a DiscoveryInterface in its constructor. So if you're calling anything other than getDefinition(s)() you're doing it wrong. And those functions usually are passed directly to the discovery anyway, so...

tim.plunkett’s picture

FileSize
5.19 KB

Rerolling #17 just to see if it still speeds things up.

EclipseGc’s picture

for the record, this is precisely what I don't want us to do. :-(

Status: Needs review » Needs work

The last submitted patch, discovery-1851706-32.patch, failed testing.

effulgentsia’s picture

Status: Needs work » Needs review
FileSize
4.75 KB

And for comparison, trying #7 again, but with static caching in the manager.

Status: Needs review » Needs work

The last submitted patch, discovery-1851706-35.patch, failed testing.

yched’s picture

Sorry to poke back at holy wars :-), but : #1863816-13: Allow plugins to have services injected
In short, if we want get rid of drupal_container() in plugin implementations, plugin managers need to hold a reference to the $container somehow.
Then, $plugin->discovery == $the_manager means $plugin cannot serialize, and that's not a place where we want to be :-/

effulgentsia’s picture

Thinking about this more, I now see 3 solid reasons favoring passing $this->discovery instead of $this:

  1. PHP typehinting is not strict. Even if the factory typehints to DiscoveryInterface, if you pass it the full manager, it can invoke any of its methods. So, passing $this->discovery ensures a smaller surface area of contact.
  2. Per #37, the need for $plugin to be serializable even if $plugin_manager isn't, so not wanting $plugin to reference its manager.
  3. Since the common pattern is for $manager->discovery to include a cache decorator, so that's where static caching already is, and since PHP stack calls aren't free, it's more performant.

OTOH, the main reason for passing $this instead of $this->discovery is so that we guarantee that factories get the same definitions as application code in the case where the manager's getDefinition(s)() implementations are not mere proxies to the discovery object.

So, I think the real question here might be whether we foresee any plugin managers in core implementing getDefinition(s)() that are not mere proxies to the discovery object, and that's very related to #1853382: Remove ProcessDecorator in favor of a solution that is in line with the original intent. and what we end up doing with ProcessDecorator. However, we've been banging our heads on the ProcessDecorator problem for a while now, and haven't yet solved it.

Given all this, how about this as a way to proceed: we do #32 for now, given the benefits listed above, but we leave open the possibility of somehow solving the ProcessDecorator problem in a way that restores the ability of core plugin managers to do something non-trivial in their getDefinition(s) implementations, at which time, we can refine the decision as to what our default pattern is and when to deviate from it?

yched’s picture

So, as @effulgentsia pointed in #1863816-16: Allow plugins to have services injected, there's a problem with plugin serialization in both cases anyway:
Even if $my_plugin->discovery is $manager->discovery rather than $manager, it still references $manager in most cases because of processDecorator($this, 'processDefinition');.

Proposed fix : #1875182: Pass plugin definition to plugin instances instead of discovery object

yched’s picture

(regarding this specific issue, #38 is still valid IMO, even though item 2) is in fact moot)

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
5.91 KB

The discussion cropped up again with msonnabaum, just rerolling this.

I'll go poke at #1875182: Pass plugin definition to plugin instances instead of discovery object as well.

EclipseGc’s picture

OK, I've not looked at #1875182: Pass plugin definition to plugin instances instead of discovery object but that sounds like an issue that needs fixing. Passing the definition instead of the manager->definition is a much better solution in my opinion. This only really matters for plugins extending PluginBase though. Still conceptually++ to that.

I'm still very much against $this->discovery being passed instead of $this. The flexibility of the system to support either is sort of the point here, and I don't think we should be legislating what all managers everywhere should always do. The reason Managers implement these interfaces is to allow flexibility in all these areas. We should strive to be as consistent as possible, and provide comments when we choose not to be. As such my counter proposal is that we standardize on $this, and not freak out when a plugin manager uses $this->discovery instead. It just means working with that particular plugin manager could occasionally involve some additional WTFs with regard to its discovery process. That will obviously be part of the learning involved with that Manager. I'd prefer we NOT enforce that same sort of WTF everywhere. I'm not really interested in what core is ACTIVELY doing in this regard. The ability of symfony bundles to allow for this stuff to be swapped out and extended means we should do the thing which will be most straight forward for developers USING these plugin managers, not the thing which could make their lives more difficult but will immediately make sense to plugin type writers. Learning to write plugin types is not a small thing, there are a lot of details, and this is just one of those issues developers will have to learn. If they don't do it the suggested way, there are ramifications. I'm very -- to standardizing on $this->discovery.

Eclipse

Status: Needs review » Needs work

The last submitted patch, discovery-1851706-41.patch, failed testing.

msonnabaum’s picture

We should always default exposing the most limited public interface possible when passing objects around for delegation. Designing for maximum flexibility without solid use cases is a recipe for complexity, which we have a bit of a problem with.

If we're type hinting DiscoveryInterface, then lets pass an object that only implements that interface. If there's a legitimate reason for PluginManager to be passed, we should change the typehint.

There's some considerable conceptual overhead to the idea that PluginManager implements the interfaces of objects it delegates to, and it can possibly pass itself to them.

Considering the fact that any plugin manager can choose to pass $this if they want to, it seems totally obvious to change the default. It's beyond a special case, it's incestuous.

jthorson’s picture

Failure was a testbot problem. Test has been requeued.

EclipseGc’s picture

PHP typehinting is not strict. Even if the factory typehints to DiscoveryInterface, if you pass it the full manager, it can invoke any of its methods. So, passing $this->discovery ensures a smaller surface area of contact.

That's great but it's not reliable. You go on to point out:

OTOH, the main reason for passing $this instead of $this->discovery is so that we guarantee that factories get the same definitions as application code in the case where the manager's getDefinition(s)() implementations are not mere proxies to the discovery object.

Which of course has been our basic argument from the beginning. I'd be happy seeing this thread die and us not commit anything. Again there's not a good reason to standardize this as there are use cases for both. I'd prefer we guarantee the application code and the factory get the same things all the time.

Per #37, the need for $plugin to be serializable even if $plugin_manager isn't, so not wanting $plugin to reference its manager.

We apparently have an issue to solve this already, so I think we can remove it from the reasons not to do this? This is actually a problem of the DefaultFactory and PluginBase expectations, not a problem of passing the plugin manager to the factory.

Since the common pattern is for $manager->discovery to include a cache decorator, so that's where static caching already is, and since PHP stack calls aren't free, it's more performant.

I actually pointed this out in reference to entities, and how the manager should probably be the implementor of cache, and not rely on a decorator, which I think this gets to the heart of the problem here. We have made some great decorators, so great in fact that core might not need anything else. Yay for us. But truly, none of that changes the fact that the plugin manager could and perhaps should be the one implementing some of this. Furthermore, I intend on getting back to the patch that rips the process decorator out of core as well, and that has implications here. I feel like we're putting on blinders and ignoring the very real fact that things look so weird right now because the plugin maintainers made some concessions to keep certain use cases moving, and that we always intended those to be temporary, and we're not past feature/api freeze yet. With that said, I propose we, at the VERY LEAST, postpone this. If all the relevant dates come and go and we've not changed the code in such a way that this doesn't make sense anymore, then I'll stop being a blocking pain in the butt, but we're not there yet, and I, for one, would like to opportunity to factor out the concessions we made early on.

catch’s picture

I'd like to know what the performance implications of this are before it gets postponed on any other issues, yched's description makes it sound like things are pretty bad as it is currently.

yched’s picture

Adding cacheDecorator as part of the discovery was the tripping point for "the discovery object is the single, standalone source of runtime plugin definitions, and the manager should just proxy the results and not add processing of its own".
In that scenario, I thus remain convinced that passing the manager instead of the discovery to the factory is useless and has no reason to be the norm. The definitions handed by both are going to be the same, so if the factory *needs* the manager, that's because it needs to call some other methods, and thus shouldn't hint for DiscoveryInterface.

If cachedecorator moves out of the discovery stack, and discovery just becomes "collecting initial data", with processing & caching somehow done by the manager, then the manager becomes "the only valid runtime source for plugin definitions", then sure, manager is what gets passed to the factory - but the factory probably wouldn't claim it needs a discovery object anyway ?

EclipseGc’s picture

The factory needs the definitions. If we don't pass it some discovery object, then it can't get the associated class for a given plugin id. It's given a discovery object to prevent the need for getting all definitions on plugin instantiation.

As I've said a couple times already, I'm not opposed to various plugin managers making the decision to pass $this->discovery instead of $this, but this issue appears to be one about policy, and I'm just asking we postpone a policy decision, not that we prevent any plugin manager from making a good decision for itself. i.e. I'm not going to attempt to block a specific manager's move to $this->discovery just because I am ideologically opposed to it on the whole. Nor will I try to push through patches that move all plugin managers to passing just $this. I will however attempt to block a policy decision at this point when the plugin subsystem has made a number of concessions I'd prefer to see factored out. I hope that's a reasonable request, this seems the sort of change we could make at almost any time before code freeze.

There are good use cases for both.

Eclipse

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
915 bytes
5.97 KB

The worry here is about which class has the canonical discovery. Only when the manager overrides getDefinitions() does the manager take responsibility away from the discovery. This patch respects that.

EclipseGc’s picture

Status: Needs review » Reviewed & tested by the community

No longer worth the effort.

RTBC assuming tests pass.

EclipseGc’s picture

For the record this makes unexpected behaviors more likely, requires us to always make new decorator classes for our discovery processes (no in manager overrides) and prevents the possibility of more informative exceptions in the factory. Also, when unexpected behaviors happen, it'll require a ridiculous amount of knowledge about the plugin system in order to trouble shoot it.

Eclipse

tim.plunkett’s picture

That's only if people override methods on their manager. As a contrib developer, I always copy/paste from core when learning something, and this will lead to writing decorators. Then there won't be any problems.

The only issue will be if they choose to deviate from core's behavior, but don't go far enough.

Status: Reviewed & tested by the community » Needs work
Issue tags: -needs profiling

The last submitted patch, discovery-1851706-50.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: +needs profiling

#50: discovery-1851706-50.patch queued for re-testing.

EclipseGc’s picture

Look, it's not like the plugin development process didn't include a significant discussion on this topic. We did it this way to begin with. We moved away from this approach for good reason. If core doesn't want to learn from that, fine, it is what it is. I'm unwilling to discuss it further. Core's doing it wrong, we lose all sorts of benefits by doing it this way, and apparently no amount of reasoning is going to change that. You don't have to justify it further, I concede. Go and do it wrong. I have more important things to spend my energy on.

Eclipse

yched’s picture

Status: Needs review » Reviewed & tested by the community

requires us to always make new decorator classes for our discovery processes (no in manager overrides)

That's not something introduced by this patch, this has been true since CacheDecorator was added as part of the discovery stack.

EclipseGc’s picture

No that is untrue. No number or type of Decorators have the slightest effect on this topic. This is only relevant if you do not allow the plugin manager to handle the responsibilities that belong to it. By passing $this->discovery instead of $this, you are doing exactly that, usurping the manager's responsibilities.

Eclipse

tim.plunkett’s picture

FileSize
5.16 KB

#1892462: EntityManager should use the CacheDecorator took care of the EntityManager hunks. This is the same patch as above, minus that.

The last submitted patch, discovery-1851706-59.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: +needs profiling

#59: discovery-1851706-59.patch queued for re-testing.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community
tstoeckler’s picture

RTBC++

webchick’s picture

Status: Reviewed & tested by the community » Needs review

This is tagged "needs profiling" but I see not any profiling. And in #47 catch asks for it again.

effulgentsia’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -needs profiling

The direction this took is towards the faster option (one less PHP call from the manager to the discovery object for every use by the factory), so profiling isn't needed. Had other reasons swayed it to the other option, then profiling would have been needed to know which managers that was acceptable on, and which ones are too much in the critical path.

EclipseGc’s picture

Status: Reviewed & tested by the community » Needs review

had a discussion with webchick about this tonight, and I think I have some good examples about exactly why this bothers me. So I'm going to set this to NR pending one last follow up. If this is still unconvincing, then fine we'll just re-rtbc the existing patch, but I'd like to make one last pass on this before we just make a blanket decision here.

Eclipse

EclipseGc’s picture

errr... it's late, sorry.

EclipseGc’s picture

Status: Needs review » Reviewed & tested by the community

OK, ran a new solution past fago and timplunkett in IRC, follow up can be found here:

#1903346: Establish a new DefaultPluginManager to encapsulate best practices

Let's rtbc this and fix it in a follow up.

Eclipse

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Glad you all were able to come to an agreement on this.

Committed to 8.x. WIll push in a few mins.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.