欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

如何修复“文件系统中缺少以下模块...”警告消息 How to fix "The following module is missing from the file system..." warning messages 有大用 有大大用 有大大大用 有大大大大用

如果您在您的网站上看到诸如“文件系统中缺少以下模块...”(或类似内容)之类的 PHP 警告,此页面将说明如何修复它。

该警告是在 Drupal 7.50 中引入的,当 Drupal 试图在文件系统中查找模块或主题时显示,但无法找到它或未在预期位置找到它。通常这表明您的网站存在问题。这不是一个大问题,但如果可能的话,理想情况下应该解决这个问题。(有关为什么添加此警告的更多信息,请参阅更改记录,以及如何确保此类警告消息永远不会显示给您站点的最终用户,而仅记录在管理日志中的这些说明。

请注意,您网站上现在导致此警告的问题或不一致可能已经存在很长时间,没有任何明显的症状。Drupal 7.50 中引入的警告消息确实使其可见。

有几种可能的原因和相应的解决方案。

您从文件系统中删除了一个模块,而没有禁用和卸载它

可能的解决方案:

  • 恢复模块并实际禁用和卸载它(如果可能,推荐):首先,将模块恢复到文件系统中的原始位置。然后转到“模块”页面并从那里禁用/卸载它,或者使用Drush ( ,其中应替换为模块的名称)。drush dis module_name && drush pm-uninstall module_namemodule_name

  • 手动删除数据库中模块的所有痕迹。这不是推荐的解决方案,因为许多模块在禁用/卸载过程中执行重要的清理任务,并且此解决方案将导致那些被跳过。在许多情况下,这意味着如果尝试在此站点上再次使用该模块,则该模块将被破坏。但是,如果您决定使用此解决方案(例如,对于不再存在且永远无法添加回来的过时模块),可以通过多种方式完成。这里有些例子:


    • 德鲁巴 7

      • 使用 drupal.org contrib 模块提供的点击式管理界面。
        选项 #1 -模块缺失消息修复程序
        选项 #2 -缺失模块

      • 使用德鲁什

        例如,运行类似于以下的命令:

        drush sql-query "DELETE from system where type = 'module' AND name IN ('old_module1','old_module2');"
        

        完成后,清除站点的缓存(例如drush cc all)。

      • 在自定义模块中编写更新挂钩

        您可以使用类似于以下示例的代码,这将在 update.php 运行时删除缺少的模块:

        /**
         * Delete {system} records for long-lost modules.
         */
        function MYMODULE_update_7100() {
          $modules = array(
            'old_module1',
            'old_module2',
            'old_module3',
          );
          db_delete('system')
            ->condition('name', $modules, 'IN')
            ->condition('type', 'module')
            ->execute();
        }

    • Drupal 8/9

  1. 启用开发模块并在管理界面上转到/devel/config,编辑删除缺少的模块条目。 core.extension

  2. 使用 drupal.org contrib 模块提供的点击式管理界面。
    选项 #1 -模块缺失消息修复程序

  3. 使用德鲁什

    drush sql-query "DELETE FROM key_value WHERE collection='system.schema' AND name='module_name';"
    完成后,清除站点的缓存(例如drush cr)。
    还要确保 CMI 文件夹中已清除损坏的已卸载模块。可能会遗留一些 yml 文件和/或一些系统配置。(这并不是作为 FYI 做事的最佳方式。但是,由于 Drupal 8 还很年轻,事情并不总是按计划进行)。

  4. 在自定义模块中编写更新挂钩

    您可以使用类似于以下示例的代码,这将在 update.php 运行时删除缺少的模块:

    /**
     * Fix long lost modules are missing from the filesystem.
     */
    function MYMODULE_update_8100(&$sandbox) {
      $modules = [
        'old_module1',
        'old_module2',
        'old_module3',
      ];
      \Drupal::database()->delete('key_value')
        ->condition('collection', 'system.schema')
        ->condition('name', $modules, 'IN')
        ->execute();
    }
    
  1. 使用 drupal.org contrib 模块提供的点击式管理界面。
    选项 #1 -模块缺失消息修复程序
    选项 #2 -缺失模块

  2. 使用德鲁什

    例如,运行类似于以下的命令:

    drush sql-query "DELETE from system where type = 'module' AND name IN ('old_module1','old_module2');"
    

    完成后,清除站点的缓存(例如drush cc all)。

  3. 在自定义模块中编写更新挂钩

    您可以使用类似于以下示例的代码,这将在 update.php 运行时删除缺少的模块:

    /**
     * Delete {system} records for long-lost modules.
     */
    function MYMODULE_update_7100() {
      $modules = array(
        'old_module1',
        'old_module2',
        'old_module3',
      );
      db_delete('system')
        ->condition('name', $modules, 'IN')
        ->condition('type', 'module')
        ->execute();
    }
    

您在 Drupal 安装中移动了模块

可能的解决方案:

  • 清除站点的缓存,以便注册模块的新位置。或者,

  • 将模块移回文件系统中的原始位置。

来自  https://www.drupal.org/node/2487215


If you see a PHP warning such as "The following module is missing from the file system..." (or similar) on your site, this page explains how to fix it.

The warning was introduced in Drupal 7.50 and is displayed when Drupal is attempting to find a module or theme in the file system, but either cannot find it or does not find it in the expected place. Usually this indicates a problem with your site. It is not a major problem, but one which should ideally be fixed if possible. (See the change record for more information on why this warning was added, and these instructions for how to ensure that warning messages like this one are never displayed to your site's end users, but rather only recorded in the administrative logs.)

Note that the problem or inconsistency on your site, which is now causing this warning, might have been existing for a long time already, without any visible symptoms. The introduction of the warning message in Drupal 7.50 does make it visible.

There are a few possible causes and corresponding solutions.

You removed a module from the file system without disabling and uninstalling it

Possible solutions:

  • Restore the module and actually disable and uninstall it (recommended if possible): First, restore the module to its original location in the file system. Then either go to the Modules page and disable/uninstall it from there, or use Drush (drush dis module_name && drush pm-uninstall module_name, where module_name should be replaced with the name of the module).

  • Manually remove all traces of the module in the database. This is not the recommended solution because many modules do important cleanup tasks during the disable/uninstall process, and this solution will result in those being skipped. In many cases it will mean that the module will be broken if an attempt is ever made to use it again on this site. However if you decide to use this solution (e.g. for obsolete modules that do not even exist anymore and that can never be added back), it can be done in several ways. Here are some examples:

  • Drupal 7

    • Use the point-and-click, administrative interface provided by drupal.org contrib modules.
      Option #1 - Module Missing Message Fixer
      Option #2 - Missing Module

    • Use Drush

      For example, run a command similar to the following:

      drush sql-query "DELETE from system where type = 'module' AND name IN ('old_module1','old_module2');"
      

      When done, clear the site's caches (e.g. drush cc all).

    • Write an update hook in a custom module

      You can use code similar to the example below, which will remove the missing modules when update.php is run:

      /**
       * Delete {system} records for long-lost modules.
       */
      function MYMODULE_update_7100() {
        $modules = array(
          'old_module1',
          'old_module2',
          'old_module3',
        );
        db_delete('system')
          ->condition('name', $modules, 'IN')
          ->condition('type', 'module')
          ->execute();
      }
    •  

    • Drupal 8/9

  1. Enable devel module and on the administrative interface go to /devel/config, edit core.extension delete missing module entry.

  2. Use the point-and-click, administrative interface provided by drupal.org contrib modules.
    Option #1 - Module Missing Message Fixer

  3. Use Drush

    drush sql-query "DELETE FROM key_value WHERE collection='system.schema' AND name='module_name';"
    When done, clear the site's caches (e.g. drush cr).
    Also make sure that the CMI folder is cleansed of the broken uninstalled module. There may be some yml files left over and / or some system config. (this is all not the best way to do things as a FYI. However with Drupal 8 being so young, things don't go as planned always).

  4. Write an update hook in a custom module

    You can use code similar to the example below, which will remove the missing modules when update.php is run:

    /**
     * Fix long lost modules are missing from the filesystem.
     */
    function MYMODULE_update_8100(&$sandbox) {
      $modules = [
        'old_module1',
        'old_module2',
        'old_module3',
      ];
      \Drupal::database()->delete('key_value')
        ->condition('collection', 'system.schema')
        ->condition('name', $modules, 'IN')
        ->execute();
    }
    
  1. Use the point-and-click, administrative interface provided by drupal.org contrib modules.
    Option #1 - Module Missing Message Fixer
    Option #2 - Missing Module

  2. Use Drush

    For example, run a command similar to the following:

    drush sql-query "DELETE from system where type = 'module' AND name IN ('old_module1','old_module2');"
    

    When done, clear the site's caches (e.g. drush cc all).

  3. Write an update hook in a custom module

    You can use code similar to the example below, which will remove the missing modules when update.php is run:

    /**
     * Delete {system} records for long-lost modules.
     */
    function MYMODULE_update_7100() {
      $modules = array(
        'old_module1',
        'old_module2',
        'old_module3',
      );
      db_delete('system')
        ->condition('name', $modules, 'IN')
        ->condition('type', 'module')
        ->execute();
    }
    

You moved the module inside your Drupal installation

Possible solutions:

  • Clear the site's caches so the new location of the module is registered. Or,

  • Move the module back to its original location in the file system.

来自  https://www.drupal.org/node/2487215




普通分类: