WordPress.org

Make WordPress Core

Changeset 34030


Ignore:
Timestamp:
09/11/2015 01:25:21 AM (4 years ago)
Author:
pento
Message:

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.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/schema.php

    r33774 r34030  
    136136CREATE TABLE $wpdb->options (
    137137  option_id bigint(20) unsigned NOT NULL auto_increment,
    138   option_name varchar(64) NOT NULL default '',
     138  option_name varchar(191) NOT NULL default '',
    139139  option_value longtext NOT NULL,
    140140  autoload varchar(20) NOT NULL default 'yes',
  • trunk/src/wp-admin/includes/upgrade.php

    r33734 r34030  
    538538    if ( $wp_current_db_version < 33056 )
    539539        upgrade_431();
     540
     541    if ( $wp_current_db_version < 34030 )
     542        upgrade_440();
    540543
    541544    maybe_disable_link_manager();
     
    15971600
    15981601/**
     1602 * Executes changes made in WordPress 4.4.0.
     1603 *
     1604 * @since 4.4.0
     1605 *
     1606 * @global int  $wp_current_db_version Current version.
     1607 * @global wpdb $wpdb                  WordPress database abstraction object.
     1608 */
     1609function upgrade_440() {
     1610    global $wp_current_db_version, $wpdb;
     1611
     1612    if ( $wp_current_db_version < 34030 ) {
     1613        $wpdb->query( "ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)" );
     1614    }
     1615}
     1616
     1617/**
    15991618 * Executes network-level upgrade routines.
    16001619 *
  • trunk/src/wp-includes/version.php

    r33981 r34030  
    1212 * @global int $wp_db_version
    1313 */
    14 $wp_db_version = 33056;
     14$wp_db_version = 34030;
    1515
    1616/**
Note: See TracChangeset for help on using the changeset viewer.