- Issue created by @Steven Snedker
- 🇫🇷France lazzyvn paris
Yes, I just removed sub module threejs editor. You can downgrade 1.0.2 and remove threejs editor sub-module and update 1.0.4 later. Or you can wait for the next version 1.0.5, I will bring threejs editor back
- 🇩🇰Denmark Steven Snedker
Do you know if there's a correct way to remove submodules from your module?
ChatGPT has this suggestion which to me sounds right on:
If another user has not uninstalled one of your submodules and updates to the new version of your module that no longer includes that submodule, they will indeed get a fatal "submodule not found" error.
To prevent this error from occurring, you can add an update hook to your module that checks for the presence of the submodule and uninstalls it if it's found.
Here's an example of how you can do this:
Create a new file in your main module's directory called my_module.post_update.php.
In this file, create a function that checks if the submodule exists, and if it does, uninstalls it. Here's an example:
function my_module_remove_submodule() { $submodule_name = 'submodule_to_remove'; if (\Drupal::moduleHandler()->moduleExists($submodule_name)) { \Drupal::service('module_installer')->uninstall([$submodule_name]); } }
In this example, replace submodule_to_remove with the actual name of the submodule that you're removing.
In your main module's .info.yml file, add the following line:
post_update: my_module_remove_submodule
This tells Drupal to run the my_module_remove_submodule function when the module is updated.
Now, when a user updates to the new version of your module, Drupal will automatically check for the presence of the removed submodule and uninstall it if it's found, preventing the fatal "submodule not found" error.
God bless ChatGPT!
The core developers have been discussing how to make the module system less fickle for years and years 🐛 Moving modules breaks system Active .
But until they make the system more robust, I fear it's up to us to jump through these hoops in order not to break stuff.
Thank you for your work on the Threejs field 3d Object module.
- Status changed to Fixed
8 months ago 12:51pm 15 March 2024 Automatically closed - issue fixed for 2 weeks with no activity.