Fixed bug with WordPress 5.8.7 and PHP 8
-
Sorry I don’t know where to report bugs. The Media Cleaner wouldn’t load so I fixed it by changing two instructions in core.php in wpmc_create_database() functions in wp-content\plugins\media-cleaner\classes folder. I changed the following code in core.php in wpmc_create_database() function: From this;
wpmc_create_database() { /* These two instructions crash in Media Cleaner ** Might be bug in WordPress in ** wp-admin/includes/upgrade.php? */ dbDelta( $sql ); dbDelta($sql); }To this:
wpmc_create_database() { $wpdb->query($sql); $wpdb->query($sql); }Here’s the whole new code for wpmc_create_database():
function wpmc_create_database() { global $wpdb; $table_name = $wpdb->prefix . "mclean_scan"; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id BIGINT(20) NOT NULL AUTO_INCREMENT, time DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL, type TINYINT(1) NOT NULL, postId BIGINT(20) NULL, path TINYTEXT NULL, size INT(9) NULL, ignored TINYINT(1) NOT NULL DEFAULT 0, deleted TINYINT(1) NOT NULL DEFAULT 0, issue TINYTEXT NOT NULL, PRIMARY KEY (id) ) " . $charset_collate . ";" ; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); // error_log($sql); $wpdb->query($sql); // dbDelta( $sql ); // error_log("after crash"); $sql="ALTER TABLE $table_name ADD INDEX IgnoredIndex (ignored) USING BTREE;"; $wpdb->query($sql); $table_name = $wpdb->prefix . "mclean_refs"; $charset_collate = $wpdb->get_charset_collate(); // This key doesn't work on too many installs because of the 'Specified key was too long' issue // KEY mediaLookUp (mediaId, mediaUrl) $sql = "CREATE TABLE $table_name ( id BIGINT(20) NOT NULL AUTO_INCREMENT, mediaId BIGINT(20) NULL, mediaUrl TINYTEXT NULL, originType TINYTEXT NOT NULL, PRIMARY KEY (id) ) " . $charset_collate . ";"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); $wpdb->query($sql); // dbDelta( $sql ); }Here’s the old code:
function wpmc_create_database() { global $wpdb; $table_name = $wpdb->prefix . "mclean_scan"; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id BIGINT(20) NOT NULL AUTO_INCREMENT, time DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL, type TINYINT(1) NOT NULL, postId BIGINT(20) NULL, path TINYTEXT NULL, size INT(9) NULL, ignored TINYINT(1) NOT NULL DEFAULT 0, deleted TINYINT(1) NOT NULL DEFAULT 0, issue TINYTEXT NOT NULL, PRIMARY KEY (id) ) " . $charset_collate . ";" ; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); $sql="ALTER TABLE $table_name ADD INDEX IgnoredIndex (ignored) USING BTREE;"; $wpdb->query($sql); $table_name = $wpdb->prefix . "mclean_refs"; $charset_collate = $wpdb->get_charset_collate(); // This key doesn't work on too many installs because of the 'Specified key was too long' issue // KEY mediaLookUp (mediaId, mediaUrl) $sql = "CREATE TABLE $table_name ( id BIGINT(20) NOT NULL AUTO_INCREMENT, mediaId BIGINT(20) NULL, mediaUrl TINYTEXT NULL, originType TINYTEXT NOT NULL, PRIMARY KEY (id) ) " . $charset_collate . ";"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Fixed bug with WordPress 5.8.7 and PHP 8’ is closed to new replies.