Skip to content

Commit

Permalink
Limit index key name
Browse files Browse the repository at this point in the history
  • Loading branch information
balexey88 committed Aug 27, 2024
1 parent 75e0b42 commit e5e1d07
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions lib/classes/class-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ public function create_db() {

$charset_collate = $this->wpdb->get_charset_collate();

/**
* Based on wp-admin/includes/schema.php
*/
$max_index_length = 150;

$sql = "CREATE TABLE $this->files (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`post_id` bigint(20) unsigned NULL DEFAULT NULL,
Expand Down Expand Up @@ -182,7 +187,7 @@ public function create_db() {
`self_link` text NOT NULL,
PRIMARY KEY (`id`),
KEY post_id (post_id),
UNIQUE KEY post_id_size (post_id, size_name)
UNIQUE KEY post_id_size (post_id, size_name($max_index_length))
) $charset_collate;
CREATE TABLE $this->file_meta (
Expand All @@ -192,7 +197,7 @@ public function create_db() {
`meta_value` longtext NOT NULL,
PRIMARY KEY (`id`),
KEY post_id (post_id),
UNIQUE KEY post_id_key (post_id, meta_key)
UNIQUE KEY post_id_key (post_id, meta_key($max_index_length))
) $charset_collate;";

require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ License: GPLv2 or later
Requires PHP: 8.0
Requires at least: 5.0
Tested up to: 6.5.4
Stable tag: 4.0.4
Stable tag: 4.0.4-TEST757

Upload and serve your WordPress media files from Google Cloud Storage.

Expand Down
2 changes: 1 addition & 1 deletion wp-stateless-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://stateless.udx.io/
* Description: Upload and serve your WordPress media files from Google Cloud Storage.
* Author: UDX
* Version: 4.0.4
* Version: 4.0.4-TEST757
* Text Domain: stateless-media
* Author URI: https://udx.io
* License: GPLv2 or later
Expand Down

0 comments on commit e5e1d07

Please sign in to comment.