Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#56533 new defect (bug)

dbDelta() ignores changes to column nullability (NULL/NOT NULL)

Reported by: matt_fw's profile matt_fw Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 6.0.2
Component: Database Keywords: reporter-feedback
Focuses: Cc:

Description

dbDelta() ignores changes to the nullability of columns.

Test case:

<?php
$create = "CREATE TABLE dbdelta_bug_test  (
  id int(11) NOT NULL,
  value int(11) NOT NULL,
  PRIMARY KEY  (id)
);";
$update = "CREATE TABLE dbdelta_bug_test  (
  id int(11) NOT NULL,
  value int(11) NULL,
  PRIMARY KEY  (id)
);";

global $wpdb;
$wpdb->query("DROP TABLE dbdelta_bug_test");
$wpdb->query($create);

require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($update);

Expected result:
Column value is nullable.

Actual result:
dbDelta() doesn't detect any changes to the table.

Change History (2)

#1 follow-up: @costdev
2 years ago

  • Keywords reporter-feedback added

Hi @matt_fw , thanks for opening this ticket.

I'm just going through tickets and making sure they have the right Version property. As Version refers to the WordPress version that introduced the issue, rather than the version that the site is using, can you confirm whether this issue only appeared in 6.0.2, or if it exists in earlier versions?

Thanks!

#2 in reply to: ↑ 1 @matt_fw
2 years ago

Replying to costdev:

Hi @matt_fw , thanks for opening this ticket.

I'm just going through tickets and making sure they have the right Version property. As Version refers to the WordPress version that introduced the issue, rather than the version that the site is using, can you confirm whether this issue only appeared in 6.0.2, or if it exists in earlier versions?

Thanks!

Indeed, I selected the WP version witch which I tested the code. My bad, sorry. I suspect the bug was always there. Which version should I select? I don't have an option to change it to 'unknown' or 'none'.

Note: See TracTickets for help on using tickets.