Make WordPress Core

Opened 14 years ago

Closed 11 years ago

Last modified 11 years ago

#16698 closed defect (bug) (worksforme)

Better Table field value upgrade check (minor)

Reported by: cogmios's profile cogmios Owned by:
Milestone: Priority: normal
Severity: minor Version: 1.5
Component: Warnings/Notices Keywords: close
Focuses: Cc:

Description

line 1463 on /wp-admin/includes/upgrades.php is

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

$fieldtype = $matches[1];

There is no check IF a $matches is found. If there is no match found an error will be displayed 'undefined index 1'. An Error message could be added here.

Can happen : if the sql code contains no spaces between the fieldname and the type it will generate the not found [1].

Change History (4)

#1 @hakre
14 years ago

  • Component changed from General to Warnings/Notices
  • Keywords reporter-feedback added

Hi cogmios,

thanks for reporting the issue. Can you provide some steps on how to trigger the notice so to better look for a fix?

#2 @cogmios
14 years ago

  • Cc deleau@… added

this should trigger it:

$sql = "CREATE TABLE $table_name_1 (
 id bigint(20) NOT NULL AUTO_INCREMENT,
 urivarchar(2048) COLLATE utf8_unicode_ci NOT NULL,
 favicon varchar(10) COLLATE utf8_unicode_ci NOT NULL,
 filters varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 content varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 defaulticon tinyint(1) NOT NULL,
 comment varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 icon_parent_id bigint(20) NOT NULL,
 itime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
 PRIMARY KEY  (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";

:) (no space before varchar, which is a mistake but the error message is confusing)

#3 @c3mdigital
11 years ago

  • Keywords close added; needs-patch reporter-feedback removed
  • Resolution set to worksforme
  • Status changed from new to closed
  • Type changed from enhancement to defect (bug)
  • Version changed from 3.1 to 1.5

I can't reproduce the reporters undefined index error. Running dbDelta and passing in the supplied create table statement I get a proper MySql error message:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(2048) COLLATE utf8_unicode_ci NOT NULL, favicon varchar(10) COLLATE utf8_unico' at line 3

cogmios,

If you can still reproduce this please reopen this ticket.

#4 @helen
11 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.