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;
    }
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Ahmad Khader created an issue. See original summary.

ahmad khader’s picture

StatusFileSize
new1.01 KB
nicholass’s picture

Status: Needs review » Reviewed & tested by the community

This patch worked for me thanks!

renatog’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for your contribution

Two suggestions:

1) Dependency Injection
There is construct so it can use dependency injection instead of \Drupal::service()

2) Variable format

  • Variable $adminTasks is using lowerCamelCase
  • Variable $perms_link is using snake_case

Both are valid but Drupal Coding Standards recommends:

Be consistent; do not mix camelCase and snake_case variable naming inside a file

samit.310@gmail.com made their first commit to this issue’s fork.

manish-31 made their first commit to this issue’s fork.

manish-31’s picture

Status: Needs work » Needs review

I 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.

DYdave made their first commit to this issue’s fork.

manish-31’s picture

Rebased MR and resolved Merge conflicts.

dydave’s picture

Category: Bug report » Task
Issue summary: View changes

Hi 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_helper was 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!

dydave’s picture

Thanks 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!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.