[wp-trac] [WordPress Trac] #20263: Backticks in dbDelta cause warning and actually causes a query to alter all columns and indexes to run even if none have changed

WordPress Trac wp-trac at lists.automattic.com
Sat Sep 1 20:13:24 UTC 2012


#20263: Backticks in dbDelta cause warning and actually causes a query to alter all
columns and indexes to run even if none have changed
-----------------------------+------------------------------
 Reporter:  Driskell         |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Upgrade/Install  |     Version:  1.5
 Severity:  minor            |  Resolution:
 Keywords:  has-patch        |
-----------------------------+------------------------------

Comment (by timfs):

 What's so complicated? Took me 10 seconds:

 {{{
 preg_match("|`?" . preg_quote($tablefield->Field) . "`? ([^ ]*(
 unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
 }}}

 This also fixes problems with tablenames that contain "special"
 characters, in MySQL for example '''foo.bar.[b-a-z]''' is a perfectly
 valid tablename, besides using non-sanitized external input is always a
 very bad idea.

 However, this Regex is pretty fragile anyways, it can't handle multiple
 spaces, it can't handle tabs, it can't handle spaces between the
 parentheses enclosing the column length, etc... someone should really
 rewrite that whole stuff, it might explode by a slight sneeze.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20263#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list