Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Remove non-existent permissions function to be used for upgrades with missing static and dynamic permissions #10

Closed
Natshah opened this issue Oct 30, 2023 · 2 comments

Comments

@Natshah
Copy link
Member

Natshah commented Oct 30, 2023

Have you faced an issue with missing static or dynamic permissions while updating?
or after disabling/uninstalling a module?

RuntimeException: Adding non-existent permissions to a role is not allowed. The incorrect permissions are "~~~~~~~". in Drupal\user\Entity\Role->calculateDependencies() (line 207 of core/modules/user/src/Entity/Role.php).

Following with:

Calculate role dependencies and remove non-existent permissions.
Which was removed in Drupal 10

Developers are facing this issue while uninstalling a module with dynamic permissions

  1. Cloned the ready function and name it removeNoneExistentPermissions in our Module Install Factory class ..
    Next to addPermissions Add Permissions for user roles from scanned directory Add Permissions for user roles from scanned directory #9

  2. Add more needed functions if you like, so we tell teams to use them in hooks . Update, modules_installed , hook_uninstall

  3. A drush command in Varbase Core could be needed for an easier way to clean and a quick fix the non-existent permissions to a role in projects.

Examples:

Example 1:

use Vardot\Installer\ModuleInstallerFactory;

/**
 * Remove non-existent permissions Testing hook update.
 */
function varbase_core_update_1011111() {

  // Remove non-existent permissions.
  ModuleInstallerFactory::removeNoneExistentPermissions();

}

Example 2 :
Given a mycustom_migrate_module module was used to migrate or update

use Vardot\Installer\ModuleInstallerFactory;


/**
 * Implements hook_uninstall().
 */
function mycustom_migrate_module_uninstall() {
  // Remove non-existent permissions Testing uninstall hook.
  ModuleInstallerFactory::removeNoneExistentPermissions();

} 

Could be used for sure in any uninstall post update event subscribers

Natshah added a commit that referenced this issue Oct 30, 2023
Natshah added a commit that referenced this issue Oct 30, 2023
Natshah added a commit that referenced this issue Oct 30, 2023
Natshah added a commit that referenced this issue Oct 30, 2023
Natshah added a commit that referenced this issue Oct 30, 2023
@Natshah
Copy link
Member Author

Natshah commented Oct 30, 2023

We can start a new issue in Varbase Core

A drush command in Varbase Core could be needed for an easier way to clean and a quick fix the non-existent permissions to a role in projects.

Maybe in the list of

drush varbase:remove-non-existent-permissions

and the other command could be
drush varbase:entity-update

@Natshah
Copy link
Member Author

Natshah commented Oct 30, 2023

✅ Released varbase_core-10.0.0-rc5
✅ Released varbase_core-9.1.7
✅ Released varbase_core-9.0.71

drush varbase:remove-non-existent-permissions

Remove non-existent permissions, to be used for upgrades with missing static and dynamic permissions

drush varbase:entity-update

Entity updates to clear up any mismatched entity and/or field definitions. Fix changes were detected in the entity type and field definitions.

Run ./bin/drush list in a Varbase site after updating to see the following

varbase:                                                                                                                                                                        
  varbase:entity-update (edupdb)                                                       Entity updates to clear up any mismatched entity and/or field definitions Fix changes    
                                                                                       were detected in the entity type and field definitions.                                  
  varbase:remove-non-existent-permissions (rnep)                                       Remove non-existent permissions, to be used for upgrades with missing static and dynamic 
                                                                                       permissions. 

@Natshah Natshah closed this as completed Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant