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

Update fails on microsite installations #125

Open
dedavidson opened this issue Jun 25, 2024 · 8 comments
Open

Update fails on microsite installations #125

dedavidson opened this issue Jun 25, 2024 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@dedavidson
Copy link

The hook_update added in #121 fails on microsite installs as the localgov_roles module is (rightly) not enabled.

@dedavidson dedavidson added the bug Something isn't working label Jun 25, 2024
@finnlewis
Copy link
Member

I wonder if we can wrap the update hook and use statements in a conditional to check if localgov_roles is enabled.

@finnlewis
Copy link
Member

Nope!

The use keyword must be declared in the outermost scope of a file (the global scope) or inside namespace declarations.

https://www.php.net/manual/en/language.namespaces.importing.php#language.namespaces.importing.scope

I can replicate the error though.

@finnlewis
Copy link
Member

Any suggestions @dedavidson @ekes @MariosORION ?

@finnlewis
Copy link
Member

Maybe we don't need the use statement, if the rest is conditional.

@dedavidson
Copy link
Author

Could turn your idea round and put the update in localgov_roles and check if localgov_geo is enabled?

@finnlewis
Copy link
Member

Could turn your idea round and put the update in localgov_roles and check if localgov_geo is enabled?

Could turn your idea round and put the update in localgov_roles and check if localgov_geo is enabled?

Could turn your idea round and put the update in localgov_roles and check if localgov_geo is enabled?

Yeah, starting to think that's the best (only?) way.

We can't wrap the use statement in a conditional.

We can't access the RolesHelper::CONTRIBUTOR_ROLE without the use statement. (or can we? )

Kind of run out of time on this for today, but keen to fix this quickly.

Anyone else got any bandwidth to try other things?

Also, if we move it, what do we do with the update hook? Leave it in place but empty?

@dedavidson
Copy link
Author

Can we use a FQN without use e.g. \Drupal\localgov_roles\RolesHelper::CONTRIBUTOR_ROLE?

@finnlewis
Copy link
Member

Can we use a FQN without use e.g. \Drupal\localgov_roles\RolesHelper::CONTRIBUTOR_ROLE?

Good shout, trying that now https://github.com/localgovdrupal/localgov_geo/pull/126/files

Seems to work fine for me locally, and if the roles don't exist, they don't get loaded, so no harm done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants