Make WordPress Core

Opened 16 years ago

Closed 13 years 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: Focuses:

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 14 years ago.

Download all attachments as: .zip

Change History (8)

#1 @hbanken
16 years ago

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

#2 @scribu
16 years ago

  • Description modified (diff)

#3 @dd32
16 years ago

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

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

#4 @wonderboymusic
14 years ago

  • Milestone Future Release → 3.6

this appears harmless to me

#5 @SergeyBiryukov
14 years ago

  • Component Upgrade/Install → Database

#6 @nacin
13 years ago

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

#7 @nacin
13 years ago

  • Owner set to nacin
  • Resolution → fixed
  • Status new → 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.