@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix an issue with collation construction on "sort" columns for old MySQL

Summary:
Fixes T7422. We'll currently choose a "binary" charset with a "utf8_general_ci" collation on "sort" columns on older MySQL, which seems to be causing problems.

Choose "utf8" in this case instead.

(I attempted to simplify the logic, too, but that's the only actual change.)

Test Plan: Went back and forth with `--disable-utf8mb4` on `storage adjust`, but this is version dependent so I'm not 100% sure it's the right fix.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7422

Differential Revision: https://secure.phabricator.com/D11928

+50 -28
+50 -28
src/applications/config/schema/PhabricatorConfigSchemaSpec.php
··· 235 235 $type = $matches[1]; 236 236 $size = idx($matches, 2); 237 237 238 - if ($is_binary) { 239 - if ($size) { 240 - $column_type = 'varbinary('.$size.')'; 241 - } else { 242 - $column_type = 'longblob'; 243 - } 244 - 245 - // MySQL (at least, under MyISAM) refuses to create a FULLTEXT index 246 - // on a LONGBLOB column. We'd also lose case insensitivity in search. 247 - // Force this column to utf8 collation. This will truncate results with 248 - // 4-byte UTF characters in their text, but work reasonably in the 249 - // majority of cases. 250 - 251 - if ($type == 'fulltext') { 252 - $column_type = 'longtext'; 253 - $charset = 'utf8'; 254 - $collation = 'utf8_general_ci'; 255 - } 256 - } else { 257 - if ($size) { 258 - $column_type = 'varchar('.$size.')'; 259 - } else { 238 + switch ($type) { 239 + case 'text': 240 + if ($is_binary) { 241 + if ($size) { 242 + $column_type = 'varbinary('.$size.')'; 243 + } else { 244 + $column_type = 'longblob'; 245 + } 246 + } else { 247 + if ($size) { 248 + $column_type = 'varchar('.$size.')'; 249 + } else { 250 + $column_type = 'longtext'; 251 + } 252 + } 253 + break; 254 + case 'sort': 255 + if ($size) { 256 + $column_type = 'varchar('.$size.')'; 257 + } else { 258 + $column_type = 'longtext'; 259 + } 260 + break; 261 + case 'fulltext'; 262 + // MySQL (at least, under MyISAM) refuses to create a FULLTEXT index 263 + // on a LONGBLOB column. We'd also lose case insensitivity in search. 264 + // Force this column to utf8 collation. This will truncate results 265 + // with 4-byte UTF characters in their text, but work reasonably in 266 + // the majority of cases. 260 267 $column_type = 'longtext'; 261 - } 262 - $charset = $this->getUTF8Charset(); 263 - if ($type == 'sort' || $type == 'fulltext') { 268 + break; 269 + } 270 + 271 + switch ($type) { 272 + case 'text': 273 + if ($is_binary) { 274 + // We leave collation and character set unspecified in order to 275 + // generate valid SQL. 276 + } else { 277 + $charset = $this->getUTF8Charset(); 278 + $collation = $this->getUTF8BinaryCollation(); 279 + } 280 + break; 281 + case 'sort': 282 + case 'fulltext': 283 + if ($is_binary) { 284 + $charset = 'utf8'; 285 + } else { 286 + $charset = $this->getUTF8Charset(); 287 + } 264 288 $collation = $this->getUTF8SortingCollation(); 265 - } else { 266 - $collation = $this->getUTF8BinaryCollation(); 267 - } 289 + break; 268 290 } 269 291 } else { 270 292 switch ($data_type) {