Skip to content

Case-insensitivity causes data loss when renaming fields #1741

@SkyLundy

Description

@SkyLundy

Short description of the issue

Renaming a field with a capitalized name that already exists in lowercase destroys the table and all data for the field you are renaming. The field that was being renamed is continues to exist under it's previous name within ProcessWire but now shows an error that its corresponding database table does not exist. First noticed in a site running v3.0.165, confirmed issue still exists in v3.0.200. Possibly affects all versions of ProcessWire.

Expected behavior

Renaming a field with a capitalized name that already exists in lowercase is recognized as unique and saves properly.

Actual behavior

Renaming a field with a capitalized name that already exists in lowercase deletes the table for the field being renamed and SQLSTATE[42S02] Base table or view not found error is shown in the admin. The field retains the original name and remains present in ProcessWire and assigned to templates.

Optional: Screenshots/Links that demonstrate the issue

table_rename_error_example
table_rename_error_example_2

Optional: Suggestion for a possible fix

Enable case-sensitivity for field names or detect field name similarity and show an error without data loss.

Steps to reproduce the issue

  1. Create a field with the name body
  2. Create a field with the name wvprofile_body
  3. Rename the field wvprofile_body to Body

Setup/Environment

  • ProcessWire version: 3.0.165
  • (Optional) PHP version: 8.0.27
  • (Optional) MySQL version: 5.7.41-log
  • (Optional) Any 3rd party modules that are installed and could be related to the issue: Isolated core issue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions