Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
path.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
3 Nov 2013 at 14:38 UTC
Updated:
29 Jul 2014 at 23:06 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
slashrsm commentedComment #2
slashrsm commentedComment #3
slashrsm commentedReroll.
Comment #5
slashrsm commentedMeh... Forgot to include one file in reroll.
Comment #6
slashrsm commentedComment #7
slashrsm commented5: 2126421_4.patch queued for re-testing.
Comment #8
slashrsm commentedComment #9
dawehnernitpick: should be {@inheritdoc}
We should name it a little bit different than "hook".
Most other implementations do use a constant so you can really easy find the dispatcher and subscriber of an event. See KernelEvents::REQUEST
To be honest it is odd to have both events and hooks for the same thing.
Should be {@inheritdoc}
Comment #10
slashrsm commentedThank you @dawehner. Patch update based on #9. Hooks removed. While looking for core's implementations of deleted hooks I found path_test.module. Further grepping found no tests that would use it. I removed it and will wait for test bot to prove me right or wrong :).
This will need a change notfication as we replace hooks with events.
Comment #11
dawehnerWe no longer need the module handler here + docs for the alias manager is missing.
Is it just me that event constants don't really belong in some class though more on the separate event classes?
Comment #12
slashrsm commentedI agree about events in a separate class. Don't even know why I've added them to \Drupal\Core\Path\Path in the first place...
Comment #13
slashrsm commentedComment #14
dawehnerI really like how it works now, though it is an API change to remove the hook support. Let's see what maintainers think.
Comment #15
catchI can't see any justification for replacing the hook invocations with events here. The use of events in core is extremely inconsistent, and given these are CRUD hooks this is adding to that inconsistency (compared to say entity CRUD) rather than improving it. Just seems unnecessary to me.
There was a good reason for this argument when it was added, if it's been broken by refactoring we should fix it rather than removing.
Comment #16
slashrsm commentedMain reasoning behind this change was in removal of an unecessary dependency (Path needs AliasManager to clear it's caches). There are also @todos in code, which made me think that this was planned during initial implementation (1, 2, 3). This patch makes \Drupal\Core\Path\Path much more independent, which is a very good argument IMO.
Initially I fired hooks from EventSubscriber (see #5), but they were removed after reviews (I agree with @dawehner in #9 about that).
This dependency have hit me while trying to fix #2136503: Make \Drupal\Core\Path\AliasManager storage independent, since it caused a circular dependency.
When I checked code flow of this part it made me think that there is no case where you'd need non-default argument in cache-clear context. I am still pretty sure we don't need it here, but we can definitely add it back if necessary.
Comment #17
slashrsm commentedWe discussed this with @catch the other day and he said that he'll consult other commiters about this patch. Any news in that direction?
Comment #18
chx commented13: 2126421_12.patch queued for re-testing.
Comment #19
chx commentedLet's put it back for committer feedback.
Comment #20
xjm13: 2126421_12.patch queued for re-testing.
Comment #22
slashrsm commented13: 2126421_12.patch queued for re-testing.
Comment #23
slashrsm commentedBack to RTBC as tests look fine.
Comment #24
catchAssigning to Alex for a second opinion.
I'm not sure on this one. The events save the circular dependency with the cache clear. But it's another, inconsistent, ad-hoc replacement of a hook with an event - I still really dislike the DX for events.
Comment #25
chx commentedAnd yet, routes are using events for example. Why not this one?
Comment #26
alexpottUsing events is fine by me - especially in the routing system and where we want a service to respond to something.
Just make the path.alias_manager_cache service an event listener. No need for the additional service and less code to maintain.
Comment #27
catchI don't think path aliases are the routing system, they're more a configuration/content entity that hasn't been converted yet.
Comment #28
slashrsm commentedEventSubscriber moved from new class to AliasManagerCacheDecorator as suggested by @alexpott.
Comment #29
slashrsm commentedComment #30
chx commentedWhile the documentation on the PathEvent class does not make any sense and is quite confusing, Symfony which is declared to superior to Drupal, uses the same terminology so this is apparently ready.
Comment #31
dawehnerWe can also just @inheritdoc this piece here.
we use camelcase for variables.
Let's typehint the interface instead.
Comment #32
alexpottsetting back to needs work due to @dawehner's review
Comment #33
slashrsm commentedThank you for the review. All issues from #31 should be fixed.
Comment #34
amateescu commentedFWIW, I agree with this and with the fact that we shouldn't use events here.
Comment #35
alexpott@amateescu & @catch - so how is the
AliasManagerCacheDecoratorsupposed to react to the hooks?Comment #36
amateescu commented@alexpott, the hooks can be implemented by a module (path I would say) and invoke the appropiate methods on AliasManagerCacheDecorator? @chx noted in IRC that path.module is not required, but then I wonder why we even have a Drupal\Core\Path namespace instead of having everything nicely contained in the path module..
Comment #37
chx commentedpath is really path_ui . that said, hooks can live in system. system is often the hook container for such things, anyways.
Comment #38
slashrsm commentedRe-implementation with hooks. Let's see what testbot says about this.
Comment #40
chx commentedUnlike module_invoke_all of old, you dont pass a variable number of arguments to invokeAll, it's invokeAll($hook, array())
Comment #41
slashrsm commentedComment #43
slashrsm commented41: 2126421_41.patch queued for re-testing.
Comment #44
slashrsm commentedComment #45
chx commentedIf we don't like events then \Drupal::service() it is.
Comment #46
alexpottIs there any point to the source parameter? Now that this patch removes the source parameter from
AliasManagerInterface::cacheClear()? Maybe there is a reason in contrib for this but it does appear from the comment that we are no longer only rebuildingthe whitelist if the system path has a top level component which is not already in the whitelist.Comment #47
slashrsm commentedIt looks that this was introduced in #723634: path_save() performance for performance reasons. There were two main reasons for initial implementation to cause problems; nasty db query and variable_set() on every clear/rebuild.
The whole thing is implemented a bit differentely in D8 and neither of those two is there anymore. I also did a bit of testing and was not getting any regression on save as number of aliases have grown. @catch should definitely vote on this being author of the patch that introduced this improvement.
I'd say kill it entirely if we're not introducing performance regression with it.
Comment #48
catchSo the idea with that parameter was this:
- when a path is inserted/updated, it's often for paths like node/123 or user/456 via pathauto.
- if node/user is already in the path alias whitelist, there's really no need to clear the cache.
@slashrsm, the regression won't be on save, but on the cost of rebuilding the path alias whitelist on the next request.
It's quite possible this is already broken in HEAD, but it might be a regression compared to 7.x to kill it.
Comment #49
slashrsm commentedOK. Let's bring that param back to life.
Comment #50
tim.plunkettAre we sure we don't want to keep this @todo?
Comment #51
slashrsm commentedOK. Let's keep that.
Comment #52
amateescu commented@tim.plunkett, @slashrsm, this very issue decided to *not* use an event there, so why should we keep the @todos? :)
Comment #53
slashrsm commented@amateescu: Events are still cleaner solution IMO (you must agree that invoking precudural hook from OO code to clear some internal caches in another OO code doesen't seem very nice and clean solution). However, I can agree with @catch that having two systems that do exactly the same thing (i.e. hooks and events) causes a lot of confusions and that's why I'm fine with this solution.
The point of this issue is to decouple two parts of the system. Please do not convert it to a general "events pro et contra" discussion.
Comment #54
dawehnerI wonder whether we should use the cached version as well to ensure that it also reflected in the cached one. Maybe we could/should also use \Drupal instead.
It is certainly sad to see that we make system.module bigger again, but yeah for now we cannot really avoid that sadly. It seems to be that we should use the ' path.alias_manager.cached' service instead ...
Comment #55
slashrsm commentedComment #56
alexpottNo longer needs a change record as nothing is new here.
Patch looks good.
Comment #57
alexpottComment #58
catchCommitted/pushed to 8.x, thanks!
Comment #59
slashrsm commentedYay! Thank you all!