Fix database collation for utf8mb4_unicode_ci columns#229
Conversation
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Code Review
This pull request updates the database upgrade queries in includes/functions-upgrade.php for version 5.0.6, converting the URL table to utf8mb4_bin and adjusting the collations of the title and ip columns. A critical issue was identified where removing the explicit column change for keyword in the upgrade path from older versions prevents reducing its length from VARCHAR(200) to VARCHAR(100). This can trigger index key length limit errors on certain MySQL/MariaDB configurations and cause schema inconsistency. It is recommended to restore the explicit change clause for the keyword column as suggested.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| "CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin, " . | ||
| "CHANGE `title` `title` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, " . | ||
| "CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;", | ||
| "CHANGE `ip` `ip` VARCHAR(41) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;", |
There was a problem hiding this comment.
By removing the explicit CHANGE clause for the keyword column, this upgrade path will fail to reduce the keyword column length from VARCHAR(200) to VARCHAR(100) when upgrading from versions prior to 505.
In MySQL/MariaDB, a VARCHAR(200) column using utf8mb4 as a primary key exceeds the default 767-byte index key length limit (200 * 4 = 800 bytes). This will cause the upgrade to fail with a Specified key was too long; max key length is 767 bytes error on standard/older database configurations. Additionally, it leads to schema inconsistency between new installations (which use VARCHAR(100)) and upgraded installations.
We should restore the explicit CHANGE clause for keyword to safely reduce its length to 100 during the table conversion.
"CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin, " .
"CHANGE `keyword` `keyword` VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '', " .
"CHANGE `title` `title` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, " .
"CHANGE `ip` `ip` VARCHAR(41) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;"
The previous implementation converted all columns to
utf8mb4_bin, which wiped the requiredutf8mb4_unicode_cicollations on columns liketitleandip. This fix updatesyourls_upgrade_505_to_506andyourls_upgrade_to_506to restoreutf8mb4_unicode_cifor thetitleandipcolumns exactly after applying the globalutf8mb4_binconversion, effectively targetingkeywordandurl.PR created automatically by Jules for task 3193185667911188223 started by @projectedanx