Problem/Motivation
EDIT: The error below has been fixed in #3452633: Fix fatal 'TypeError: ModulePermissionsLinkHelper::getModulePermissionsLink(): Argument #2 ($name) must be of type string, array given':
TypeError: Drupal\user\ModulePermissionsLinkHelper::getModulePermissionsLink(): Argument #2 ($name) must be of type string, array given, called in /docroot/core/modules/system/system.module on line 992 in Drupal\user\ModulePermissionsLinkHelper->getModulePermissionsLink() (line 47 of core/modules/user/src/ModulePermissionsLinkHelper.php).
system_get_module_admin_tasks('block_class', Array) (Line: 95)
Drupal\block_class\Controller\BlockClassController->index()
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
AND
* @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use the
* 'system.module_admin_links_helper' service with the getModuleAdminLinks() method
* and 'user.module_permissions_link_helper' service with the
* ::getModulePermissionsLink() method instead.
Steps to reproduce
navigate to /admin/block-class/help
Proposed resolution
Using this code instead
$info = $this->extensionListModule->getExtensionInfo($projectMachineName);
$adminTasks = \Drupal::service('system.module_admin_links_helper')->getModuleAdminLinks($projectMachineName);
if ($perms_link = \Drupal::service('user.module_permissions_link_helper')->getModulePermissionsLink($projectMachineName, $info['name'])) {
$adminTasks["user.admin_permissions.{$projectMachineName}"] = $perms_link;
}
Comments
Comment #2
ahmad khader commentedComment #3
nicholassThis patch worked for me thanks!
Comment #4
renatog commentedThanks for your contribution
Two suggestions:
1) Dependency Injection
There is construct so it can use dependency injection instead of
\Drupal::service()2) Variable format
$adminTasksis using lowerCamelCase$perms_linkis using snake_caseBoth are valid but Drupal Coding Standards recommends:
Comment #8
manish-31 commentedI have raised Merge Request for the patch from #2 including the feedback fixes from #4. Needs review.
I have confirmed that help page does not throw this error now.
Comment #10
manish-31 commentedRebased MR and resolved Merge conflicts.
Comment #11
dydave commentedHi Manish (@manish-31),
Thanks a lot for the merge request and code contributions.
According to the change record: system_get_module_admin_tasks() is deprecated as of D10.2.0 where the new service
system.module_admin_links_helperwas introduced and currently used in your merge request:https://git.drupalcode.org/project/block_class/-/merge_requests/37/diffs...
If we were to merge these changes we would be breaking backward compatibility (BC) and this feature would not work with D10.1, D10.0 or D9, which means we would have to drop support for 10.1 and only support 10.2 and above.
In order to get MR!37 merged, we're going to have to create the new minor release branch 2.1.x which will drop support for D10.1.
For the time being, the error mentioned in the issue summary has been fixed in related ticket #3452633: Fix fatal 'TypeError: ModulePermissionsLinkHelper::getModulePermissionsLink(): Argument #2 ($name) must be of type string, array given' with changes committed to the 2.0.x branch.
We should be able to come back to this ticket soon... once we've got other non breaking changes added to the current 2.0.x branch.
Feel free to let us know if you have any questions or concerns on this comment or the ticket in general, we would surely be glad to help.
Thanks!
Comment #12
dydave commentedThanks again everyone for the great work and documentation in this issue.
The problem has been resolved in related #3412155: Deprecated system_get_module_admin_tasks in drupal:10.2.0 and is removed from drupal:11.0.0.
Marking issue as Closed (Duplicate) in favor of the new one.
Thanks again very much!
Comment #14
dydave commented