From 0d85038ce60adfd2c43bee9f96dc253342d6c23f Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 11 Sep 2015 01:26:24 +0000 Subject: [PATCH] Schema: Increase the length of `wp_options.option_name`. It's pretty easy to run over the `option_name` length, which causes undefined behaviour when inserting and retrieving options. Increasing the length from `VARCHAR(64)` to `VARCHAR(191)` significantly reduces the risk of this occurring. Because `option_name` has a `UNIQUE` index, we can only increase it to 191 characters, rather than 255. The index can only use a prefix of 191 characters, so will incorrectly restrict long different strings that have the same prefix, if we make the column longer. Props scribu, OriginalEXE, khromov, MikeHansenMe, netweb, pento. Fixes #13310. Built from https://develop.svn.wordpress.org/trunk@34030 git-svn-id: http://core.svn.wordpress.org/trunk@33999 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/schema.php | 2 +- wp-admin/includes/upgrade.php | 19 +++++++++++++++++++ wp-includes/version.php | 4 ++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 75e8f5bfba..4eb6bca715 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -135,7 +135,7 @@ CREATE TABLE $wpdb->links ( ) $charset_collate; CREATE TABLE $wpdb->options ( option_id bigint(20) unsigned NOT NULL auto_increment, - option_name varchar(64) NOT NULL default '', + option_name varchar(191) NOT NULL default '', option_value longtext NOT NULL, autoload varchar(20) NOT NULL default 'yes', PRIMARY KEY (option_id), diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 72c3328fc9..967cfe38f3 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -538,6 +538,9 @@ function upgrade_all() { if ( $wp_current_db_version < 33056 ) upgrade_431(); + if ( $wp_current_db_version < 34030 ) + upgrade_440(); + maybe_disable_link_manager(); maybe_disable_automattic_widgets(); @@ -1595,6 +1598,22 @@ function upgrade_431() { } } +/** + * Executes changes made in WordPress 4.4.0. + * + * @since 4.4.0 + * + * @global int $wp_current_db_version Current version. + * @global wpdb $wpdb WordPress database abstraction object. + */ +function upgrade_440() { + global $wp_current_db_version, $wpdb; + + if ( $wp_current_db_version < 34030 ) { + $wpdb->query( "ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)" ); + } +} + /** * Executes network-level upgrade routines. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 19d1786912..c0c0b1ba9b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,14 +4,14 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34028'; +$wp_version = '4.4-alpha-34030'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * * @global int $wp_db_version */ -$wp_db_version = 33056; +$wp_db_version = 34030; /** * Holds the TinyMCE version