Drupal 10 升级后,出现“用户 ID 字段需要更新”的问题。

After Drupal 10 upgrade , having an issue "The User ID field needs to be updated."

提问人:Banshidhari 提问时间:11/17/2023 最后编辑:Banshidhari 更新时间:11/17/2023 访问量:33

问:

Drupal 10升级后,我遇到了如下截图所示的问题:enter image description here

我确实尝试了命令drush entity-updates并得到如下错误:

The following updates are pending:

user entity type : 
The User ID field needs to be updated.

 Do you wish to run all pending updates? (yes/no) [yes]:
 > yes


In SqlContentEntityStorageSchema.php line 1843:
                                                                                                  
  The SQL storage cannot change the schema for an existing field (uid in user entity) with data.  
                                                                                                  

然后我发现有几篇文章提到要检查模式是否正确,然后我还使用以下行代码与我的旧网站进行检查,并且两者都是相同的:

echo '<pre>';
print_r(\Drupal::keyValue('entity.storage_schema.sql')->get('user.entity_schema_data'));
print_r(\Drupal::keyValue('entity.storage_schema.sql')->get('user.field_schema_data.uid'));

输出

Array
(
    [users] => Array
        (
            [primary key] => Array
                (
                    [0] => uid
                )

        )

    [users_field_data] => Array
        (
            [primary key] => Array
                (
                    [0] => uid
                    [1] => langcode
                )

            [indexes] => Array
                (
                    [user__id__default_langcode__langcode] => Array
                        (
                            [0] => uid
                            [1] => default_langcode
                            [2] => langcode
                        )

                )

            [unique keys] => Array
                (
                    [user__name] => Array
                        (
                            [0] => name
                            [1] => langcode
                        )

                )

        )

)
Array
(
    [users] => Array
        (
            [fields] => Array
                (
                    [uid] => Array
                        (
                            [type] => int
                            [unsigned] => 1
                            [size] => normal
                            [not null] => 1
                        )

                )

        )

    [users_field_data] => Array
        (
            [fields] => Array
                (
                    [uid] => Array
                        (
                            [type] => int
                            [unsigned] => 1
                            [size] => normal
                            [not null] => 1
                        )

                )

        )

)

大多数文章都说,如果我运行命令drush entity-updates,那么问题可能会得到解决,不幸的是没有希望。我要提前感谢您的帮助。

Drupal PHP-8 Drupal-10

评论

0赞 Xab Ion 11/22/2023
尝试编辑用户 ID 字段并保存。有时这可能会有所帮助。我在另一个字段中遇到了类似的错误,其中编辑和保存字段对我有用。还可以尝试使用 refresing database、drush updb 和清除缓存。

答: 暂无答案