Skip to content

fix(migrations): keep the file_groups charset when making paths case-sensitive (3.6) - #2676

Open
elcreator wants to merge 2 commits into
evolution-cms:3.6.xfrom
elcreator:fix-file-groups-collation-keep-charset-36
Open

elcreator wants to merge 2 commits into
evolution-cms:3.6.xfrom
elcreator:fix-file-groups-collation-keep-charset-36

Conversation

@elcreator

@elcreator elcreator commented Dec 5, 2026 •

Copy link
Copy Markdown

3.6 copy of #2675: the migrations, the helper, the tests, the CI legs and the AGENTS.md section are the same files on both lines.

The new MyISAM CI legs fail on 3.6 in the bundled sTask package, not in core. seiger/stask v2.3.2 (database/migrations/2025_10_15_000000_create_task_tables.php) indexes default-length strings:

  • s_workers: unique identifier (VARCHAR(255): 1020 bytes in utf8mb4);
  • s_tasks: index (identifier, action) (1530 bytes even in utf8mb3).

Both are past the MyISAM limit of 1000 bytes. So a 3.6 install on MyISAM, and an upgrade of a MyISAM 3.5 site to 3.6, stop with 1071 there. I shortened those columns in a local vendor copy as a probe: the upgrade leg then passes, and the install leg passes every MySQL check. Fix: Seiger/sTask#30. These legs stay red until it is released and the 3.6 lock picks it up. With that branch in place of the vendor copy, both legs pass every MySQL check locally.

An update from 3.5.9 stops in 2026_10_11_000000_make_file_groups_file_case_sensitive when file_groups is a MyISAM table with a utf8mb3 column (an older site on MySQL 8.0, connection config engine MyISAM, charset utf8):

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
(SQL: ALTER TABLE `evo_file_groups` MODIFY `file` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '')

The migration converted the column to utf8mb4 on the way to a binary collation. That widens the indexed VARCHAR(255) from 765 to 1020 bytes, past the MyISAM key limit of 1000. make:site finish stops there: the new files are in place, but the update seeders, the Extras module, the settings version and the removal of install/ never run, so the manager reports the leftover install folder.

MyISAM is a supported engine, not a legacy one: the installers write it into the connection config for servers older than MySQL 5.7.6, and sites keep it. Checking the whole chain on MyISAM found a second gap: on a MyISAM site with a utf8mb4 connection, even a fresh install failed. The create migration's unique key (document_group, file VARCHAR(255)) needs 4 + 1020 bytes. The table stayed behind without its indexes, and the next migrate skipped it (hasTable()) and reported success.

Changes

  • core/includes/file_groups_schema.php, loaded by path (a migration must not depend on a classmap rebuild). It provides:
    • the engine and charset a new table gets (connection config, else server defaults; utf8 resolves to utf8mb3 on MySQL 8.0.30+);
    • the bytes per character;
    • the binary collation as the server names it (utf8_bin on 5.7, utf8mb3_bin on 8.0);
    • the longest file the unique key allows (249 for MyISAM with utf8mb4, 255 otherwise).
  • 2026_10_11 changes only the collation, keeping the charset and the length.
  • Create migration (both copies):
    • declares the binary collation itself, so 2026_10_11 has nothing left to do on a new site;
    • creates file as VARCHAR(249) on MyISAM with utf8mb4. The unique key still covers the full, case-exact path, with no prefix.
  • 2026_12_05_000000_restore_file_groups_indexes (new, idempotent):
    • restores the indexes of a table that hit the key limit;
    • shortens file only when no stored path is longer;
    • drops duplicate rows, keeping the oldest;
    • when a stored path is longer, keeps the rows, restores only the group index and writes the reason to the event log.
    • A table with all its indexes is left alone.
  • Review (thanks): collation names are matched with RIGHT(COLLATION_NAME, 4) = '_bin'. Under NO_BACKSLASH_ESCAPES, LIKE '%\_bin' matched nothing on MySQL 8.0.46 and 9.7.4, and the migration would have been recorded without changing anything. The CI scripts match the table prefix with LEFT() for the same reason.
  • CI:
    • ci.yml: an install leg on MySQL with MyISAM (EVO_DB_ENGINE), whose updater pass replays the chain over it.
    • upgrade.yml: a nightly / on-demand leg (legacy: myisam) that turns the older site into MyISAM / utf8mb3 before upgrading it (legacy-myisam.php).
    • smoke.php checks the file_groups unique key and binary collation on MySQL, and the engine of every table when one was asked for.
    • The unit-test job starts MySQL for the lowest PHP version and runs FileGroupsMysqlTest there (EVO_TEST_MYSQL).
  • AGENTS.md: a "Migrations on MySQL: MyISAM and older charsets" section with the rules behind this (key budget per engine and charset, change only what the migration is for, server-named collations, repair after a partial create, both migration copies, CI legs).

A site already stuck on it can finish before this is released:

  1. Give the column its binary collation in its own charset. For utf8mb3:
    ALTER TABLE evo_file_groups MODIFY file VARCHAR(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL DEFAULT '';
  2. Run php artisan make:site finish in core/.

Tests

  • FileGroupsStorageEngineTest (SQLite, always runs): key budget per engine and charset, engine/charset resolution, server collation names, the generated ALTER, both copies of the create migration, and the three migrations on SQLite.
  • FileGroupsMysqlTest (needs EVO_TEST_MYSQL), in the default SQL mode and under NO_BACKSLASH_ESCAPES:
    • the collation lookup;
    • an old MyISAM utf8mb3 table: charset and length kept, becomes _bin;
    • a new MyISAM utf8mb4 table: VARCHAR(249), all indexes;
    • InnoDB: 255;
    • the repair: indexes back, duplicates dropped, case variants kept, an over-long path kept.
    • Passes on MySQL 5.7.44, 8.0.46, 9.7.4 and MariaDB 10.11.
  • Full 3.6 suite: 3179 passed, 38 skipped. FileGroupsMysqlTest on the 3.6 tree against MySQL 9.7: all pass.
  • CI scripts, run locally against mysql:9.7 on the 3.5 line (fix(migrations): keep the file_groups charset when making paths case-sensitive #2675); on 3.6 see the sTask note above:
    • install on MyISAM: all checks pass, including the updater pass;
    • 3.5.7 turned MyISAM / utf8mb3, upgraded to this branch: passes.
    • The same two legs on a tree with only the CI changes and the old migrations fail with 1071, so they catch this class of error.
  • End to end on MySQL 8.0 (3.5 line, fix(migrations): keep the file_groups charset when making paths case-sensitive #2675): 3.5.9 installed, file_groups made MyISAM utf8mb3, 3.5.12 laid over it. make:site finish fails as above. Laying this branch over it, or applying the manual ALTER on 3.5.12, completes it: exit 0, install/ removed, no pending migrations.

🤖 Generated with Claude Code

…sensitive

The 2026_10_11 migration converted file_groups.file to utf8mb4. On a MyISAM
table with a utf8mb3 column that widens the indexed VARCHAR(255) to 1020
bytes, past the MyISAM key limit of 1000, and the update stops with error
1071. Change only the collation, to the binary one of the column's own
character set, named as the server spells it (utf8_bin on MySQL 5.7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Seiger commented Dec 5, 2026

Copy link
Copy Markdown

The same migration code is used here, so the MySQL collation lookup blocker noted in #2675 applies to 3.6.x as well. Please carry over the SQL-mode-independent suffix check and the regression test to this branch before merging.

— SokilAI

…QL engines in CI

MyISAM is a supported engine: the installers write it for older servers and
sites keep it, often with a utf8 (utf8mb3) connection. The file_groups
migrations now respect its 1000-byte key limit:

- core/includes/file_groups_schema.php, loaded by path: the engine and
  charset a new table gets, bytes per character, the binary collation as the
  server names it (RIGHT(), not LIKE '%\_bin', which matches nothing under
  NO_BACKSLASH_ESCAPES), and the longest `file` the unique key allows.
- The create migration (both copies) declares the binary collation itself and,
  on MyISAM with utf8mb4, creates `file` as VARCHAR(249).
- 2026_10_11 keeps the column length as well as its charset.
- 2026_12_05_000000_restore_file_groups_indexes puts back the indexes a create
  that hit the key limit left out, drops the duplicates it let in, and keeps
  rows whose path is longer than the key allows.

CI: an install leg on MySQL with MyISAM, a nightly upgrade of a site turned
MyISAM / utf8mb3 (legacy-myisam.php), smoke checks for the file_groups key and
collation and the engine of every table, and FileGroupsMysqlTest run against a
real server (EVO_TEST_MYSQL) in both SQL modes. AGENTS.md lists the rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@elcreator

Copy link
Copy Markdown
Author

Carried over in c9ea053: the same RIGHT(COLLATION_NAME, 4) = '_bin' lookup and the same FileGroupsMysqlTest, which passes on the 3.6 tree against MySQL 9.7 in both SQL modes. Details are in the reply on #2675.

One thing specific to 3.6: the new MyISAM CI legs stop in the bundled seiger/stask v2.3.2, not in core.

  • s_workers: unique identifier, a VARCHAR(255) of 1020 bytes in utf8mb4.
  • s_tasks: index (identifier, action), 1530 bytes even in utf8mb3.

Both are past the MyISAM limit of 1000 bytes. Until sTask sizes those columns, a 3.6 install on MyISAM and an upgrade of a MyISAM 3.5 site to 3.6 fail with 1071, and these legs stay red. The PR description has the probe results.

@elcreator

Copy link
Copy Markdown
Author

The sTask side is in Seiger/sTask#30. It sizes the indexed columns so every key fits the MyISAM limit, repairs tables a failed MyISAM create left without keys, and makes the models refuse longer values. With that branch in place of the vendor copy, the 3.6 MyISAM install and the MyISAM / utf8mb3 upgrade from 3.5.7 pass every MySQL check locally. Once it is released, this PR needs the lock bumped.

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

Successfully merging this pull request may close these issues.

2 participants