Occasionally, a Drupal site may display a warning about a module being "Missing or invalid." This issue occurs when a module is marked as installed in the configuration but is no longer present in the file system. A common example is the `fakeobjects` module, which is associated with CKEditor 4 and may remain in the configuration after CKEditor 4 is uninstalled.
Understand the issue
The warning occurs because Drupal stores module information in the `core.extension` configuration. If a module is no longer present on the server, it is flagged as "missing." This situation often arises when modules are removed indirectly (e.g., CKEditor 4 uninstalling its plugins).
To clean up the system, the missing module must be removed from the configuration.
Export the configuration as a backup (optional)
Before making changes, it is good practice to back up your site's current configuration:
drush config-export
or
drush cex
This will save your site's configuration files to the `config/sync` directory. This backup allows you to revert changes if needed.
Edit core.extension to remove the module
To remove the `fakeobjects` module, you need to edit the `core.extension` configuration where installed modules are listed. There are two approaches:
Using Drush
drush config-edit core.extension
Find and remove the line referencing `fakeobjects` under the `module:` section.
Manually editing the configuration file
1. Open the `core.extension.yml` file in your `config/sync` directory.
2. Locate the `fakeobjects` entry in the `module:` section and delete it.
module:
fakeobjects: 0
Update the database directly (if needed)
If the module still appears as missing after editing the configuration, you may need to update the database:
- Access the database using a tool like phpMyAdmin or a command-line client.
- Query the `config` table to find the `core.extension` configuration:
SELECT * FROM config WHERE name = 'core.extension';
- Edit the configuration record and remove any references to the `fakeobjects` module.
Re-import the updated configuration
Once the changes have been made, re-import the updated configuration to apply them to your site:
drush config-import
or
drush cim
Clear the cache
Clear Drupal's cache to ensure the changes take effect:
drush cr
Verify the module has been removed
Finally, check that the missing module no longer appears:
drush pm-list --status=missing
If the module is no longer listed, the removal was successful.
General tips for handling missing modules
- Always back up your database and configuration before making significant changes.
- Check if other custom modules or themes rely on the missing module before removal.
- Test your site thoroughly after making changes to ensure no functionality has been disrupted.
By following this process, you can cleanly remove any missing module from your Drupal site and avoid configuration warnings. Using `fakeobjects` as an example, this approach ensures your site remains clean and functional after module-related changes.