Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL Index issue for utf8mb4 #63

Open
selay opened this issue Sep 8, 2018 · 1 comment
Open

MySQL Index issue for utf8mb4 #63

selay opened this issue Sep 8, 2018 · 1 comment

Comments

@selay
Copy link

selay commented Sep 8, 2018

The module breaks Silverstripe 4+ site if you are using utf8mb4 unicode which requires full 4 bytes.
Although not tested (I simply removed this module and can have a look later), I guess the issue is caused by

 private static $indexes = array(
        'From' => array(
            'type' => 'unique',
            'columns' => array(
                'FromBase',
                'FromQuerystring',
            ),
        ),
    );

as it uses combined indexing.

The reason why it is a bug because Silverstripe itself supports full 4 bytes, and ideally the module would at least support the same requirements. SiteTree also uses Varchar(255) for URLSegment but that is fine.

Errors:

Couldn't run query:\n\nALTER TABLE \"RedirectedURL\" CHANGE \"ClassName\" \"ClassName\" enum('SilverStripe\\\\RedirectedURLs\\\\Model\\\\RedirectedURL') character set utf8mb4 collate utf8mb4_unicode_ci default 'SilverStripe\\\\RedirectedURLs\\\\Model\\\\RedirectedURL',\nCHANGE \"FromBase\" \"FromBase\" varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci,\nCHANGE \"FromQuerystring\" \"FromQuerystring\" varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci,\nCHANGE \"To\" \"To\" varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci\n\n42000-1071: Specified key was too long; max key length is 767 bytes at ...\\vendor\\silverstripe\\framework\\src\\ORM\\Connect\\DBConnector.php:64)"} []

To replicate the issue, place this in your app.yml or mysite.yml and run dev build

  SilverStripe\ORM\Connect\MySQLDatabase:
    connection_charset: utf8mb4
    connection_collation: utf8mb4_unicode_ci
    charset: utf8mb4
    collation: utf8mb4_unicode_ci
@Rhym
Copy link

Rhym commented Jul 2, 2019

I came across this today, and fixed it with the following yml config:

---
name: utf8mb4_sizing
---
SilverStripe\RedirectedURLs\Model\RedirectedURL:
  db:
    FromBase: 'Varchar(150)'
    FromQuerystring: 'Varchar(100)'

Hope this helps anyone Googling the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants