# 启用草稿与发布时，'status' 不能用作属性名称

> Source: https://strapi.nodejs.cn/cms/migration/v4-to-v5/breaking-changes/reserved-attributes-status

🌐 `status` cannot be used as an attribute name when Draft & Publish is enabled

在 Strapi 5 中，`status` 是 Document Service API 和 REST API 用来区分草稿和已发布内容的保留参数。在启用草稿与发布的内容类型中，如果用户自定义了同名的属性 `status`，将会导致命名冲突。

🌐 In Strapi 5, `status` is the reserved parameter used by the Document Service API and REST API to distinguish draft and published content. A user-defined attribute also named `status` on a Draft & Publish-enabled content type causes a naming collision.

此页面是[重大更改数据库](/cms/migration/v4-to-v5/breaking-changes)的一部分，提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。

🌐 This page is part of the [breaking changes database](/cms/migration/v4-to-v5/breaking-changes) and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

- Is this breaking change affecting plugins? Yes
- Is this breaking change automatically handled by a codemod? No

## 重大变更描述 {#breaking-change-description}

🌐 Breaking change description

**在 Strapi v4 中**

启用了草稿和发布的内容类型可以具有名为 `status` 的用户定义属性。该属性名称与使用 `publicationState` 参数的发布工作流之间不存在冲突。

🌐 Content types with Draft & Publish enabled can have a user-defined attribute named `status`. No conflict exists between this attribute name and the publication workflow, which uses the `publicationState` parameter.

**在 Strapi 5 中**

`status` 是 Draft & Publish 的保留查询参数（它取代了 `publicationState`）。在启用了 Draft & Publish 的内容类型上定义名为 `status` 的用户属性会导致命名冲突。Strapi 5 对此限制的执行如下:

- **内容类型构建器:** 阻止在启用了“草稿与发布”的任何内容类型上创建 `status` 属性。同样，也阻止在已经有 `status` 属性的内容类型上启用“草稿与发布”。
- **服务器启动：** 当检测到 `status` 属性与草稿和发布同时存在时，会记录一次警告（每个内容类型 UID 一次）。服务器会继续启动，因此现有项目不会被破坏。

## 迁移 {#migration}

🌐 Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

🌐 This section regroups useful notes and procedures about the introduced breaking change.

### 注意 {#notes}

🌐 Notes

- `status` 属性名称也是 Strapi 5 中全局保留名称的更大列表的一部分。完整列表请参见 [某些属性和内容类型名称是保留的](/cms/migration/v4-to-v5/breaking-changes/attributes-and-content-types-names-reserved) 。
- 此重大更改增加了上下文特定的限制：只有在内容类型启用“草稿与发布”时，才会强制执行 `status` 冲突。
- 有关 `status` 参数如何用于查询草稿和已发布内容的详细信息，请参阅 [Draft & Publish](/cms/features/draft-and-publish)。

### 手动操作 {#manual-procedure}

🌐 Manual procedure

如果内容类型具有 `status` 属性并且启用了草稿与发布（或你打算启用它），请在启用草稿与发布之前重命名 `status` 属性。

🌐 If a content type has a `status` attribute and Draft & Publish is enabled (or you intend to enable it), rename the `status` attribute before enabling Draft & Publish.

1. 在内容类型构建器中，打开具有 `status` 属性的内容类型。
2. 将 `status` 属性重命名为非保留名称（例如，`approval_status` 或 `workflow_state`）。
3. 点击**保存**以应用模式更改。
4. 更新任何引用旧 `status` 属性名称的查询、控制器、服务、策略或前端代码。
5. 如果“草稿和发布”被阻止启用，请在内容类型的**高级设置**选项卡中重新启用它。
