Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
user system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Dec 2014 at 22:05 UTC
Updated:
28 Feb 2015 at 19:57 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #1
larowlanComment #2
moshe weitzman commentedLooks good. Similarly, a huge offender is our compile+dump of the container for each module that gets enabled. Needs a different solution though.
Comment #3
larowlanyep
Comment #4
larowlanComment #5
larowlan8 hr test run?
Comment #6
catchIf this runs end of request, we should should be able to remove this too - looks like a bad workaround for a race condition on install - I'd probably have just said no links allowed in permissions descriptions tbh.
Comment #8
larowlanoh simpletest
Comment #9
larowlanparent meta is critical, so claiming it
Comment #10
wim leersLooks great.
I wonder if we can get rid of
user_modules_installed()altogether, listening for a configuration system event instead that indicates thecore.extensionconfig was modified?Should default to FALSE.
The message is no longer there, which is fine, but it should be converted into a comment to allow people in the future to understand more easily what exactly this is testing.
Comment #11
larowlanThanks
Yes, except I'm pretty sure that event fires 38 times too - so we'd still need the terminate event.
Comment #12
catchConfirmed #6 is correct - see test run on https://www.drupal.org/node/2396325
Comment #13
berdirI think the call was necessary before we made ModuleInstaller::install() automatically call rebuildIfNeeded(). Agreed that it can be removed.
Did you test this with drush or with the web installer? Because in the web installer, this will still run once per batch page.
Also, the comparison isn't really fair. You also need to include the time the service now takes :)
Comment #14
berdirAnd last, if most of the time spent in there is inside YamlDiscovery, then most of that will go away with #2395143: YAML parsing is very slow, cache it with FileCache.
Comment #15
larowlanYeah its tested with drush, can't profile batch yet - but you're right it will run once per batch - but that's still an improvement on once per module right?
Comment #16
larowlanRemoves rebuild, let's see how it goes
Yes a lot of the time is spent in Yaml, but a lot is spent in the Role::save too.
Comment #17
dawehnerHelp me out here, why don't we just use
$permission_handler->moduleProvidesPermissions()with the new installed$modules?This would allows us to just scan the modules, which are actually installed.
Comment #18
larowlanPerfect
Comment #19
wim leersOf course!
Comment #20
larowlanUses #17
Comment #22
larowlan@moshe weitzman see https://www.drupal.org/node/2396939 for tackling the container
Comment #23
larowlanthe editor_file_reference plugin does not exist? unrelated?
Comment #25
larowlanthis still causes a full yaml discovery/scan for each module - see the code.
So patch at #16 is more performant - reuploading it here.
Comment #26
dawehner@larowlan
Is there a specific reason why we can't the internal implementation of PermissionHandler to perform better for cases when moduleProvidesPermissions is called? I can't see a reason why it shouldn't be possible.
Comment #27
yched commentedNitpick, but if that is a PermissionHandler, why not $permissionHandler ?
Current name sounds like it stores a list of permissions for some user.
$this->role ? isn't that rather $this->adminRole ?
Surprised this is green :-)
Comment #28
larowlandawehner - will take a look - good idea
Yched good pickups, yes test must be a false positive, will expand/investigate
Comment #29
larowlan@dawehner I think #2339487: Static cache permissions would be the place to explore making PermissionsHandler::getPermission() accept an optional $module argument
Comment #30
larowlanFixes issues from #27 and adds a new test
Comment #32
larowlanpatch at #30 included #20, backed it out
Comment #33
dawehneri am really suprised that not a single test relies upon that the admin role is actually directly set. Note: for a simpletest the destruct() will never be called.
Just add a needs_destruction tag as well as implement the
DestructableInterfaceWith that you could skip implement the event subscriber again. Maybe there is a reason why you haven't implemented it.
Comment #34
yched commentedJust wondering - #2230637: Create a Language field widget and the related formatter just added the following in language_modules_installed($modules) :
Does it mean it will need similar treatment, or is it OK because it's only done if 'language' is one of the modules enabled ?
Comment #35
larowlanThat should be OK
Comment #36
fabianx commented#33: Can you elaborate, you say this should use DestructableInterface instead and not be an event subscriber?
Are there other examples using DestructableInterface for end-of-request building? e.g. router builder?
CNW based on #33 to get some progress here.
Comment #37
dawehner@36
Note: DestructableInterface is simply a wrapper around
KernelEvents::TERMINATEwith some nicer API, seeKernelDestructionSubscriberComment #38
fabianx commentedThis will not save any time nor memory now that standard profile installs the admin_role setting, so this is only called after standard profile is installed.
It would also not save any time for non-drush applications as module installation is per batch anyway, so while I liked the idea this just introduces complexity for no win.
- The call to ->setRebuildNeeded() should be removed generically though. ModuleInstaller already does that.
- The call to ->getPermissions in standard.profile should be removed.
But the 37 calls will only do a Config::get by now (to check the admin_role setting which takes 0.5 ms) and is fine.
What _could_ be done here (though its a little inconvenient) is to only add permissions of the newly added modules, but then standard.profile would again need to install all permissions, so this would again not save any time in the installer.
And the biggest 2.5 s and costly (10 MB) part of this is not the role YAML parsing, but the route rebuilding of the filter permissions, which is then saved for the next request.
Putting to active as the patch is (outdated).
Comment #39
dawehnerI guess we can mark this issue as duplicate of #2435075: Implement admin role as a flag on the role storage, simplify permissions page, remove user_modules_installed
Comment #40
fabianx commentedClosed as duplicate of #2435075: Implement admin role as a flag on the role storage, simplify permissions page, remove user_modules_installed.
Thanks for the work that did go into this issue @all!