Problem/Motivation

Our team manages a lot of Drupal sites which we are upgrading from Drupal 8 to Drupal 9 and we have noticed an issue when modules move their file location. There are a few reasons one might do this:

  1. The module goes from being an internal submodule inside a project to being a stand-alone project that is included as a dependency
  2. The maintainers of the module have disappeared and you are required to move it into a modules/custom or modules/patched folder.

When you do this, even after running updb and cr and the whole gamut of commands Drupal might start compaining about files being missing from the old folder (whether in /docroot/modules/contrib or even /vendor). This happens throughout the UI and also when running Drush commands.

The usual resolution for this is to:

  • Uninstall the module
  • Config import to re-install the module and its settings

This is fine for most modules without a database storage component to them, but when you uninstall a module, all the data disappears. You can't use this method to stop the error messages. I have pulled the database and searched through it for references to these files and they are in there, I think mostly in dblog (because of all the errors) and also key_value.

If we were just removing the modules in question, we could use

DELETE FROM key_value WHERE collection='system.schema' AND name='module_name'

but that can't be used here because the module is still in use, just in a different location.

Drupal will often actually find this module, fortunately, and most of the functions will run fine. I have yet to have a critical error come from doing this, but I'm concerned that it's only a matter of time.

Is there a SAFE way to go through and change all the references in the database from the old file location to the new one? Should this not be an automatic process since Drupal is capable of finding modules practically anywhere?

Comments

loopy1492 created an issue. See original summary.

loopy1492’s picture

Issue summary: View changes
cilefen’s picture

Component: configuration system » extension system
Issue tags: +Bug Smash Initiative
Related issues: +#2651144: Moving modules breaks system
larowlan’s picture

Status: Active » Postponed (maintainer needs more info)

Visiting the admin/modules page is normally enough to reset this, except if you're using APC cached autoloader, which normally requires restarting containers or Apache

loopy1492’s picture

It may very well be a duplicate of that. Seems as if.

It looks like any data where this url can be found is stuck in a binary column. I'm not sure I can hunt it down that way unless anyone has a query that might be helpful.

One specific error is coming from GeoField which moved one of their Libraries from the module to an external dependency.

[error] File not found: /var/www/docroot/modules/contrib/geofield/lib/phayes-geophp/v1.2/geoPHP.inc.

So I looked for the geofield key value...

SELECT * FROM key_value WHERE collection = 'system.schema' AND NAME = 'geofield'

Which has a "value" field that is a blob. Converting to utf-8 just spits out i:8000; which has no meaning to me.

Again, I cannot uninstall this module or else I risk losing data. Is there any way to switch out the location of this file in the database with a sql command?

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

borisson_’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

I'm pretty sure this is duplicate of the other issue.

SELECT * FROM key_value WHERE collection = 'system.schema' AND NAME = 'geofield'

Which has a "value" field that is a blob. Converting to utf-8 just spits out i:8000; which has no meaning to me.

This is the version of the module, so that means that geofield is installed and no update hooks have ran, as soon as geofield_update_8001 runs, this will be an integer with value: 8001.

Again, I cannot uninstall this module or else I risk losing data. Is there any way to switch out the location of this file in the database with a sql command?

As far as I know, there isn't.