Updated: Comment 0

Problem/Motivation

The ModuleInfo was introduced to safe unnessary lookups/info file parsing.

Proposed resolution

Remaining tasks

User interface changes

API changes

Original report by @username

  • The main reason this was introduces is *gone* (the stylesheet/js stuff on module .info files)
  • There are just two backend places that use it right now, search settings and settings of a specific handler
  • There are a few places that could use it, but none seem very relevant to performance: user_admin_permissions(), Permissions::getValueOptions(), Permission::buildOptionsForm(), LayoutController::layoutPageList() (I assume this isn't used now, but could be?), field_help()
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Component: field_ui.module » base system

Fixing component.

Berdir’s picture

Status: Active » Needs review
FileSize
2.3 KB

Ok, I'm confused.

There are exactly two places left in core that use system_get_module_info(). Did we replace that with the module handler? If we did, then did we introduce a regression?

Patch converts it to cache collector but doesn't make it a service yet.

Berdir’s picture

Assigned: Unassigned » catch

So... discussed this with @katbailey and @dawehner a bit.

- The main reason this was introduces is *gone* (the stylesheet/js stuff on module .info files)
- There are just two backend places that use it right now, search settings and settings of a specific handler
- There are a few places that could use it, but none seem very relevant to performance: user_admin_permissions(), Permissions::getValueOptions(), Permission::buildOptionsForm(), LayoutController::layoutPageList() (I assume this isn't used now, but could be?), field_help()

So... should we convert it to a service or just kill it, and switch to system_get_info() in these two places (all this stuff should so much be services, oh well...)

Assigning to @catch for feedback, hope that's ok :)

catch’s picture

I'd say just kill it.

Berdir’s picture

FileSize
3.75 KB

This kills it completely. An alternative would be to keep the helper function but directly access system_get_info() in there?

Status: Needs review » Needs work

The last submitted patch, module-info-2025779-5.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review

#5: module-info-2025779-5.patch queued for re-testing.

Berdir’s picture

Assigned: catch » Unassigned

Doesn't need to be assigned to catch.

Berdir’s picture

Title: Convert ModuleInfo to CacheCollector and a service » Remove ModuleInfo as it is no longer necessary
catch’s picture

When removing this we might still want a persistent cache for system_get_info(). I'd forgotten about this issue when looking at #2060859: Make Block plugin's "category" a translatable string but that's an example where it's getting the info and doesn't need a full rebuild.

ianthomas_uk’s picture

Issue summary: View changes
Issue tags: +@deprecated
FileSize
3.64 KB

Reroll and update some documentation that used this function as an example.

Berdir’s picture

Status: Needs review » Needs work
+++ b/core/includes/bootstrap.inc
@@ -2594,12 +2594,12 @@ function drupal_classloader_register($name, $path) {
  * Example:
  * @code
- * function system_get_module_info($property) {
- *   static $info;
- *   if (!isset($info)) {
- *     $info = new ModuleInfo('system_info', 'cache');
+ * function drupal_session_started($set = NULL) {
+ *   static $session_started = FALSE;
+ *   if (isset($set)) {
+ *     $session_started = $set;
  *   }
- *   return $info[$property];
+ *   return $session_started && session_id();
  * }
  * @endcode
  *

Hm, did a merge conflict go wrong here? This seems to be adding a new function, which doesn't make sense?

ianthomas_uk’s picture

Status: Needs work » Needs review

That's a comment that gives an example of when it is acceptable to use a static variable. The previous example is system_get_module_info() which won't exist after this patch, so I've replaced it with drupal_session_started().

dawehner’s picture

Issue summary: View changes
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Updated the issue summary to copy the reasons to remove it.

Good catch ianthomas_uk!

sun’s picture

sun’s picture

Can we move forward here? :)

Committing this allows me to remove 2-3 unnecessary items from the overly lengthy "inventory" list in #2186491: [meta] D8 Extension System: Discovery/Listing/Info...

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Berdir’s picture

Do we need a short change notice for this?

Berdir’s picture

Status: Fixed » Closed (fixed)

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