Opened 2 years ago

Closed 5 weeks ago

#15948 closed defect (bug) (fixed)

dbDelta SET Default <literal> Comment <literal>

Reported by: hbanken Owned by: nacin
Priority: normal Milestone: 3.6
Component: Database Version: 3.1
Severity: major Keywords: has-patch 3.2-early
Cc:

Description (last modified by scribu)

When dbDelta from wp_admin/includes/upgrade.php is used with a query containing different DEFAULT values than the actual TABLE in the database, dbDelta tries to update this DEFAULT value by altering the table. The regex that is used to find the new DEFAULT value is incorrect.

Right now, the regex is:

| DEFAULT '(.*)'|i

but this should be:

| DEFAULT '([^']*)'|i

...since, in the case a COMMENT value is set in the new query, the COMMENT value is also surrounded by single quotes ' COMMENT 'literal is added to the new default value.

Attachments (1)

15948.diff (681 bytes) - added by wonderboymusic 4 months ago.

Download all attachments as: .zip

Change History (8)

The regex should be | DEFAULT '([^']*)'|i
I didn't know about the WikiFormatting of ^.

  • Description modified (diff)

comment:3   dd322 years ago

  • Keywords has-patch 3.2-early added; sql regex removed
  • Milestone changed from Awaiting Review to Future Release

Seems sane enough to me, We should ensure that it matches the command as best as possible.

  • Milestone changed from Future Release to 3.6

this appears harmless to me

  • Component changed from Upgrade/Install to Database

I'm changing this to non-greedy (.*?) as it is more obvious (to me) what is going on.

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 24065:

dbDelta: When parsing out the DEFAULT value, avoid being too greedy. props hbanken, fixes #15948.

Note: See TracTickets for help on using tickets.