rankmath / seo-by-rank-math

Rank Math is a revolutionary WordPress SEO Plugin that combines the features of many SEO tools and lets you multiply your traffic in the easiest way possible :bulb: :chart_with_upwards_trend: →
https://rankmath.com
107 stars 52 forks source link

[General] Unable to create redirections tables on some sites #188

Open arunkumar-raja opened 1 year ago

arunkumar-raja commented 1 year ago

Describe the bug On the queries to create the redirections tables looked like this: CREATE TABLE wp_rank_math_redirections ( id bigint(20) unsigned NOT NULL auto_increment, sources text CHARACTER SET COLLATE _bin NOT NULL, url_to text NOT NULL, header_code smallint(4) unsigned NOT NULL, hits bigint(20) unsigned NOT NULL default '0', status varchar(25) NOT NULL default 'active', created datetime NOT NULL default '0000-00-00 00:00:00', updated datetime NOT NULL default '0000-00-00 00:00:00', last_accessed datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (id), KEY status (status) ) ;

CREATE TABLE wp_rank_math_redirections_cache ( id bigint(20) unsigned NOT NULL auto_increment, from_url text CHARACTER SET COLLATE _bin NOT NULL, redirection_id bigint(20) unsigned NOT NULL, object_id bigint(20) unsigned NOT NULL default '0', object_type varchar(10) NOT NULL default 'post', is_redirected tinyint(1) NOT NULL default '0', PRIMARY KEY (id), KEY redirection_id (redirection_id) ) ;

To Reproduce Steps to reproduce the behavior:

  1. In both queries there’s text CHARACTER SET COLLATE _bin NOT NULL which causes this error:
  2. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'COLLATE _bin NOT NULL,

Expected behavior In the code we have this, which looks wrong: sources text CHARACTER SET {$wpdb->charset} COLLATE {$wpdb->charset}_bin NOT NULL, The {$wpdb->charset}_bin part looks prone to errors, we should avoid that, and also maybe we should check if $wpdb->charset has any value before using it in the query.