woocommerce_database_max_index_length filter-hookWC 8.0.0

Filters the maximum index length in the database.

Indexes have a maximum size of 767 bytes. Historically, we haven't need to be concerned about that. As of WP 4.2, however, they moved to utf8mb4, which uses 4 bytes per character. This means that an index which used to have room for floor(767/3) = 255 characters, now only has room for floor(767/4) = 191 characters.

Additionally, MyISAM engine also limits the index size to 1000 bytes. We add this filter so that interested folks on InnoDB engine can increase the size till allowed 3071 bytes.

Usage

add_filter( 'woocommerce_database_max_index_length', 'wp_kama_woocommerce_database_max_index_length_filter' );

/**
 * Function for `woocommerce_database_max_index_length` filter-hook.
 * 
 * @param int $max_index_length Maximum index length.
 *
 * @return int
 */
function wp_kama_woocommerce_database_max_index_length_filter( $max_index_length ){

	// filter...
	return $max_index_length;
}
$max_index_length(int)
Maximum index length.
Default: 191

Changelog

Since 8.0.0 Introduced.

Where the hook is called

DatabaseUtil::get_max_index_length()
woocommerce_database_max_index_length
woocommerce/src/Internal/Utilities/DatabaseUtil.php 346
$max_index_length = apply_filters( 'woocommerce_database_max_index_length', 191 );

Where the hook is used in WooCommerce

Usage not found.