Page MenuHomePhabricator

🧬 in associated task causes fatal error on patch demo
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:
A fatal error is shown on the bottom of the page:

Fatal error: Uncaught mysqli_sql_exception: Incorrect string value: '\xF0\x9F\xA7\xAC G...' for column `patchdemo`.`tasks`.`title` at row 1 in /var/www/html/includes.php:376 Stack trace: #0 /var/www/html/includes.php(376): mysqli_stmt->execute() #1 /var/www/html/includes.php(214): get_task_data() #2 /var/www/html/index.php(232): get_wiki_data_from_row() #3 {main} thrown in /var/www/html/includes.php on line 376

I saw the same error on the 'create' page when trying to set up a demo for my patch.

What should have happened instead?:

no fatal error

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Details

Related Changes in Gerrit:
Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Use utf8mb4repos/test-platform/catalyst/patchdemo!187jhuneidiutf8mb4main
Customize query in GitLab

Event Timeline

FWIW, \xF0\x9F\xA7\xAC is the UTF-8 encoding of U+1F9EC DNA DOUBLE HELIX (🧬) if I’m not mistaken.

Wild guess: maybe the Patch Demo database is using utf8mb3 and needs utf8mb4 in order to accommodate a non-BMP emoji character?

ooh, that means I broke it when I tried to set up a patch demo for https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/1174403 (with our corresponding phab task T400151)

thcipriani triaged this task as Unbreak Now! priority.Jul 30 2025, 1:22 PM
thcipriani subscribed.

FWIW, \xF0\x9F\xA7\xAC is the UTF-8 encoding of U+1F9EC DNA DOUBLE HELIX (🧬) if I’m not mistaken.

Wild guess: maybe the Patch Demo database is using utf8mb3 and needs utf8mb4 in order to accommodate a non-BMP emoji character?

Sure enough:

MariaDB [(none)]> show variables where Variable_name like 'character%' or Variable_name like 'collation%';
+--------------------------+--------------------------------------+
| Variable_name            | Value                                |
+--------------------------+--------------------------------------+
| character_set_client     | utf8mb3                              |
| character_set_collations |                                      |
| character_set_connection | utf8mb3                              |
| character_set_database   | utf8mb3                              |
| character_set_filesystem | binary                               |
| character_set_results    | utf8mb3                              |
| character_set_server     | utf8mb3                              |
| character_set_system     | utf8mb3                              |
| character_sets_dir       | /opt/bitnami/mariadb/share/charsets/ |
| collation_connection     | utf8mb3_general_ci                   |
| collation_database       | utf8mb3_general_ci                   |
| collation_server         | utf8mb3_general_ci                   |
+--------------------------+--------------------------------------+
12 rows in set (0.001 sec)

Fortunately, there's an entertaining post for us to follow: https://mathiasbynens.be/notes/mysql-utf8mb4

Note that the immediate issue seems to have been resolved (for me) by T400151#11046800, but this issue will still presumably need addressing for the future

I didn't actually expect to resolve the issue by renaming the task, just did it in preparation of possibly re-creating the patch demo instance.

So this means, the fatal error occured on the attempt to write the 🧬 into the utf8mb3 database field. I'm a bit surprised it didn't only fail creating my wiki, but instead caused a general error on patch demo.

I'm glad this turned out to be a quick-and-easy fix.

utf8mb3 only allows characters up to 3 bytes which indeed excludes any characters. It means it only supports the Basic Multingual Plane and would rejects any characters 4 bytes utf-8 characters.

You can do some input filtering to reject inputs that is invalid utf-8 or 4 bytes characters. I am also not sure how the 4 bytes character managed to be inserted without MariaDB rejecting the INSERT statement, maybe the client is set to utf8mb4/binary?

For the context, MediaWiki / Wikimedia uses binary because at the time we used characters that were not implemented in MySQL. MediaWiki does the necessary filtering/validation and Debian defaults to utf8mb4 since Stretch (T193222), it allows Unicode characters of 4 bytes.

thcipriani renamed this task from Fatal error on patch demo to 🧬 in associated task causes fatal error on patch demo.Jul 30 2025, 9:00 PM

Change #1174553 had a related patch set uploaded (by Thcipriani; author: Thcipriani):

[mediawiki/core@master] DNM: Patch for testing

https://gerrit.wikimedia.org/r/1174553

thcipriani changed the task status from Open to In Progress.Jul 30 2025, 11:43 PM
thcipriani assigned this task to jeena.
thcipriani lowered the priority of this task from Unbreak Now! to High.
thcipriani added a subscriber: jeena.

Note that the immediate issue seems to have been resolved (for me) by T400151#11046800, but this issue will still presumably need addressing for the future

Thanks for this! Lowering to high priority.


@jeena 's got a change that should do the heavy lifting. Getting late, so we'll deploy tomorrow. Planning to merge, run a final db backup, and run the script to alter tables on db.

We ran a database migration for patchdemo today.

We took notes on this etherpad.

For phab posterity, steps:

  1. Final prod backup/final migration test on local dump of prod
  2. Merge
  3. Deploy to staging
  4. Final dump of staging db
  5. Create broken wiki on staging db
  6. Run migration on staging db and confirm it's fixed
  7. Steps 3–6, but on prod

All working, thanks for reporting!

Change #1174553 abandoned by Thcipriani:

[mediawiki/core@master] DNM: Patch for testing

Reason:

T400801 testing complete

https://gerrit.wikimedia.org/r/1174553

Change #1174553 restored by Thcipriani:

[mediawiki/core@master] DNM: Patch for testing

https://gerrit.wikimedia.org/r/1174553

Test wiki created on Patch demo by TCipriani (WMF) using patch(es) linked to this task:
https://b8e9b7b175.catalyst.wmcloud.org/w/

Test wiki created on Patch demo by TCipriani (WMF) using patch(es) linked to this task:
https://43b2909e45.catalyst.wmcloud.org/w/

Test wiki on Patch demo by TCipriani (WMF) using patch(es) linked to this task was deleted:

https://b8e9b7b175.catalyst.wmcloud.org/w/

Test wiki on [[ | Patch demo ]] by TCipriani (WMF) using patch(es) linked to this task was deleted:

https://43b2909e45.catalyst.wmcloud.org/w/

Test wiki on Patch demo by TCipriani (WMF) using patch(es) linked to this task was deleted:

https://43b2909e45.catalyst.wmcloud.org/w/