WAF: jetpack_waf_blocklog is created without the site's charset and collation

Open Beginner friendly
#55,365 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Peerapatfc is already working on this.

Since Nov 24, 2026.

  • #55371 by @Peerapatfc — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
mariadb, php, wordpress
Domain
backend, database

Research direction

Open projects/packages/waf/src/class-waf-blocklog-manager.php and read create_blocklog_table() around lines 99-116, where the CREATE TABLE string is assembled. Append $wpdb->get_charset_collate() after the closing parenthesis, as WordPress core does, then check the package's existing tests under projects/packages/waf/tests/php/ for the blocklog manager and run them. Done means the table is created with the site's collation and the tests still pass.

Written by the indexing model from the issue text.

Description

Impacted plugin

Jetpack, Protect

Quick summary

Waf_Blocklog_Manager::create_blocklog_table() builds its CREATE TABLE without $wpdb->get_charset_collate(), so wp_jetpack_waf_blocklog gets the database's default charset and collation instead of the site's. Every WordPress core table and most plugin tables are created with get_charset_collate(), so the block log ends up in a different collation from the rest of the site - or, on a database whose default is still utf8/utf8mb3, in a three-byte charset that cannot store 4-byte characters.

Source (trunk): projects/packages/waf/src/class-waf-blocklog-manager.php, create_blocklog_table(), lines 99-116.

Steps to reproduce
  1. Use a site whose database default collation differs from WordPress' choice, e.g. a database created with utf8mb4_unicode_ci while WordPress picks utf8mb4_unicode_520_ci (DB_COLLATE empty, MariaDB 12).
  2. Activate the firewall (Jetpack Protect → Firewall, or Jetpack's WAF module), which creates the block log table.
  3. Compare the collations: SELECT table_name, table_collation FROM information_schema.tables WHERE table_schema = DATABASE();

Expected: wp_jetpack_waf_blocklog uses the same collation as the other WordPress tables (utf8mb4_unicode_520_ci here).
Actual: it uses the database default (utf8mb4_unicode_ci).

Seen with Jetpack 16.4 and Jetpack Protect 7.0.0 on WordPress 7.1.5, MariaDB 12.3, on four sites.

Suggested fix: append the site's charset/collation, as core does:

$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE {$wpdb->prefix}jetpack_waf_blocklog ( ... ) $charset_collate;";
Site owner impact

Fewer than 20% of the total website/platform users

Severity

Minor

What other impact(s) does this issue have?

No revenue impact

If a workaround is available, please outline it here.

Convert the table by hand: ALTER TABLE wp_jetpack_waf_blocklog CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci; (use the site's own collation from $wpdb->get_charset_collate()).

Platform (Simple and/or Atomic)

Self-hosted

Dominant language
PHP
Stars
1.9k
Forks
910
Avg merge
1d 18h
Merged PRs (30d)
777

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/jetpack

All issues in Automattic/jetpack

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.