foreach ($some_list as $name => $filename) {
      drupal_classloader_register($name, dirname($filename));
      drupal_get_filename('module', $name, $filename);
     }

this code occurs twice in system_list, it should go into a helper function.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

Priority: Normal » Major
Issue tags: +Novice

Now we have the same code in three places after fixing a critical bug, so bumping this to major. Also tagging novice since it should be a straightforward patch. Coming from #1830170: module_list() doesn't register namespaces with the classloader when given a fixed module list..

sun’s picture

Assigned: sun » Unassigned
Priority: Major » Normal
Status: Active » Needs review
FileSize
2.3 KB

There's nothing "major" here.

Attached patch introduces system_register(), which is similar to the originally proposed _system_list_warm(), but limited to registering an extension in drupal_get_filename() and drupal_classloader().

"register" stems from lessons half-way learned via other issues. That is, because technically, we are missing the counterpart, system_unregister(), since we're currently abusing classloader namespaces for things they were not designed for. Both of the current registries should be able to cope with that, but introducing a complementing unregister should be left to a separate issue; potentially the Extensions service.

Status: Needs review » Needs work

The last submitted patch, drupal8.system-register.2.patch, failed testing.

chx’s picture

Assigned: Unassigned » sun
Priority: Normal » Major

Issue priority wise, we do not overrule core committers. Assigned wise, you remove it, you add it back.
This is why it fails:

-      drupal_get_filename('module', $name, $module['filename']);
+      system_register('module', $name, $module['filepath']);
sun’s picture

Status: Needs work » Needs review
FileSize
2.27 KB

Sorry, copy/paste mistake.

Also wasn't happy with the parameter name $filepath. So I checked, and everywhere else, we're calling that a URI now, so I renamed the parameter to $uri.

YesCT’s picture

Status: Needs review » Reviewed & tested by the community

the new function has good docs.
replaces the 3 places @catch mentions in #1 and that are mentioned in the issue summary.
and the bot came back green.
rtbc. :)

sun’s picture

Status: Reviewed & tested by the community » Needs work

I'm pretty sure that this patch no longer applies.

YesCT’s picture

Status: Needs work » Needs review

#5: drupal8.system-register.5.patch queued for re-testing.

YesCT’s picture

It applied for me locally. I'll ask the bot to retest.

YesCT’s picture

Status: Needs review » Reviewed & tested by the community

yep. still applies and passes the bot.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Looks good to me. This will need to be refactored again with the Extensions class, but at least it'll be from one place instead of three. Committed/pushed to 8.x.

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