Skip to content

Environments: Add has_pending column to translate stats table#680

Closed
ocean90 wants to merge 2 commits into
WordPress:fix-translate-stats-schemafrom
ocean90:fix-translate-stats-schema
Closed

Environments: Add has_pending column to translate stats table#680
ocean90 wants to merge 2 commits into
WordPress:fix-translate-stats-schemafrom
ocean90:fix-translate-stats-schema

Conversation

@ocean90
Copy link
Copy Markdown
Member

@ocean90 ocean90 commented Jun 5, 2026

Summary

  • Sync wp_gp_project_translation_status schema with production commit 733b8ab: add denormalized has_pending tinyint + compound index locale(locale, locale_slug, has_pending), drop the now-redundant single-column count indexes, bump id to bigint. Without it locale pages hit WordPress database error: Unknown column 'stats.has_pending' in 'WHERE' the moment a "needs attention" query runs.
  • Teach both stats writers (after-start.sh rebuild loop, import-wp-core.php post-import refresh) to populate has_pending = (waiting > 0 OR fuzzy > 0) and include it in the ON DUPLICATE KEY UPDATE clause, so the new index actually points at the right rows.

Production maintains the table manually (no migration code in the plugin) — same approach as the existing extra-tables.sql.

Test plan

  • wp-env destroy && wp-env start — fresh table created with the new column and indexes; DESCRIBE matches the production shape.
  • Live ALTER TABLE + backfill on an existing env — exactly the rows where waiting > 0 OR fuzzy > 0 flipped to has_pending = 1 (49 of 107).
  • curl /locale/en-gb/default/ → HTTP 200, no DB error in the response.
  • phpcs clean (vendor/bin/phpcs environments/translate/bin/import-wp-core.php -snq).

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props obenland, ocean90.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ocean90 ocean90 force-pushed the fix-translate-stats-schema branch from 85f7bf4 to 1fd15f6 Compare June 5, 2026 11:58
…column.

Production added a denormalized has_pending tinyint maintained by the
stats writers (= waiting > 0 OR fuzzy > 0) plus a compound index
locale(locale, locale_slug, has_pending) so the "find projects that
need attention" queries become a range scan over the pending subset
instead of a full table scan (production commit 733b8ab).

Without the column the local env hit
"WordPress database error: Unknown column 'stats.has_pending' in
'WHERE'" the moment a locale page issued one of those queries.

Mirror the new schema in extra-tables.sql (bigint id, has_pending,
compound locale index, date_added/date_modified indexes, drop the
single-column indexes on the count fields) and teach both stats
writers (after-start.sh, import-wp-core.php) to populate has_pending
so the new index actually points at the right rows.
@ocean90 ocean90 force-pushed the fix-translate-stats-schema branch from 1fd15f6 to 5b685dd Compare June 5, 2026 11:59
@ocean90 ocean90 closed this Jun 5, 2026
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