Make WordPress Core

Opened 14 years ago

Closed 12 years ago

#15948 closed defect (bug) (fixed)

dbDelta SET Default <literal> Comment <literal>

Reported by: hbanken's profile hbanken Owned by: nacin's profile nacin
Milestone: 3.6 Priority: normal
Severity: major Version: 3.1
Component: Database Keywords: has-patch 3.2-early
Focuses: 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 12 years ago.

Download all attachments as: .zip

Change History (8)

#1 @hbanken
14 years ago

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

#2 @scribu
14 years ago

  • Description modified (diff)

#3 @dd32
14 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.

#4 @wonderboymusic
12 years ago

  • Milestone changed from Future Release to 3.6

this appears harmless to me

#5 @SergeyBiryukov
12 years ago

  • Component changed from Upgrade/Install to Database

#6 @nacin
12 years ago

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

#7 @nacin
12 years ago

  • 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.