localgovdrupal / localgov_core

LocalGovDrupal Core module, for helper functions and core dependencies.
GNU General Public License v2.0
3 stars 6 forks source link

Enabling a module with config-import fails when setting permissions that don't exist yet #240

Open Polynya opened 3 months ago

Polynya commented 3 months ago

Installing LocalGov Publications using config import fails because localgov_roles_modules_installed() tries to add permissions before they exist - the new content type hasn't been imported yet. This probably applies to other LGD modules that create new content types.

I suggest localgov_roles_modules_installed() does nothing if $is_syncing is true. Can we assume that all permissions have been set already in config?

Steps to reproduce with DDEV:

ddev drush si localgov -y
ddev export-db --file=lgd.sql.gz
ddev drush en localgov_publications
ddev drush cex
ddev import-db --file=lgd.sql.gz
ddev drush deploy

Error Output:                                                                                                 
================                                                                                              
 [notice] Synchronized extensions: install book.                                                              
 [notice] Synchronized extensions: install layout_discovery.                                                  
 [notice] Synchronized extensions: install layout_paragraphs.                                                 
 [notice] Synchronized extensions: install localgov_paragraphs_layout.                                        

In Role.php line 210:                                                                                         

Adding non-existent permissions to a role is not allowed. The incorrect permissions are "create localgov_p  
ublication_page content", "create localgov_publication_cover_page content", "delete any localgov_publication  
_page content", "delete any localgov_publication_cover_page content", "delete localgov_publication_page revi  
sions", "delete localgov_publication_cover_page revisions", "delete own localgov_publication_page content",   
"delete own localgov_publication_cover_page content", "edit any localgov_publication_page content", "edit an  
y localgov_publication_cover_page content", "edit own localgov_publication_page content", "edit own localgov  
_publication_cover_page content", "revert localgov_publication_page revisions", "revert localgov_publication  
_cover_page revisions", "view localgov_publication_page revisions", "view localgov_publication_cover_page re  
visions".