πŸ‡ΊπŸ‡ΈUnited States @JeffC518

Account created on 4 August 2011, over 13 years ago
#

Recent comments

πŸ‡ΊπŸ‡ΈUnited States JeffC518

Confirmed that patch #5 works - I was in the bowels of the Drupal\Core\Config classes for a while trying to figure this one out. Mainly because it manifested in nginx as a 502 Gateway Error - so no PHP error logs.

This was showing up like this in nginx.log when attempting to manage form display for an events content type:

*878 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: xxx.xx.xx.x, server: REDACTED.local, request: "GET /admin/structure/types/manage/events/form-display HTTP/1.1

In my case, I'm upgrading a Drupal 8 site -> 9 -> 10, so I had no YML files to patch yet. I wrote a function to update the config tables if anyone is interested.

Note that this can disrupt any drush updb maintenance as well. This is where I received the memory exhausted error that led me here. If you increase the PHP memory limit to a ridiculous amount like I did (4G), you get something like this instead:

>  [notice] Update started: system_post_update_sort_all_config
> Killed

Thanks for the patch.

πŸ‡ΊπŸ‡ΈUnited States JeffC518

Thanks @marcusvsouza - I'll check out your merge request. Bootstrap is great if your custom theme is already using it, but adding it to the front end globally causes a number of conflicts on my end. I haven't seen much movement on this in awhile so wanted to make a note. If I have some time I'll see what I can contribute.

πŸ‡ΊπŸ‡ΈUnited States JeffC518

+1, definitely needed. Would this currently require creating a custom Gutenberg block?

πŸ‡ΊπŸ‡ΈUnited States JeffC518

Thanks @vensires! I figured this would be possible (to clean these permissions up programmatically) but this saved me a bunch of time. I used the concept and build a drush command out of it. I'd considered creating a module out of this as a dev utility, not sure what the uptake would be though.

E.g. adding a confirmation step in case a permission is tied to a module that someone forgot to install:

public function cleanPermissions() {
    $permissions = array_keys($this->permissionHandler->getPermissions());
    /** @var \Drupal\user\Entity\Role[] $roles */
    $roles = $this->roleStorage->loadMultiple();

    /** @var \Drupal\user\RoleStorageInterface $role */
    foreach ($roles as $role) {
      $role_permissions = $role->getPermissions();
      $diff_permissions_in_role = array_diff($role_permissions, $permissions);
      if ($diff_permissions_in_role) {
        foreach ($diff_permissions_in_role as $permission) {
          $confirm = $this->confirm('Revoke ' . $permission . ' for ' . $role->id() . '?');
          if ($confirm) {
            $this->io()->note('Revoked');
            $role->revokePermission($permission);
          }
        }
        $role->save();
      }
    }
  }

I used DI instead of the static calls if anyone is wondering, e.g.

public function __construct(EntityTypeManagerInterface $entity_type_manager, PermissionHandler $permission_handler) {
    $this->entityTypeManager = $entity_type_manager;
    $this->permissionHandler = $permission_handler;
    $this->roleStorage = $entity_type_manager->getStorage('user_role');
  }

Obviously if you have a lot of permissions, confirming each one gets annoying though. There's probably a way to add a (allow for all) command?

πŸ‡ΊπŸ‡ΈUnited States JeffC518

I looked at @daniel_j's comment first (#3) which was spot on, except for one minor thing:

you can search-and-replace on all your pathauto.pattern.*.yml, changing references to node_type to entity_bundle.node.

It should be entity_bundle:node

Per example, in a pathauto.pattern.page_by_menu.yml, mine was:

pattern: '[node:menu-link:parent]/[node:title]'
selection_criteria:
  511dc248-86a2-425b-bb21-90da8d45e2d1:
    id: <strong>node_type</strong>
    bundles:
      contact_page: contact_page

but should be:

pattern: '[node:menu-link:parent]/[node:title]'
selection_criteria:
  511dc248-86a2-425b-bb21-90da8d45e2d1:
    id: <strong>entity_bundle:node</strong>
    bundles:
      contact_page: contact_page

.. assuming it's a node of course.

Production build 0.71.5 2024