Repository navigation
Release 1.7.1: stop translating before after_setup_theme - #56
Merged
Merged
Conversation
The admin bootstrap built its module list on `plugins_loaded`, and the titles and descriptions in that list are translated. WordPress 6.7 and newer report `_load_textdomain_just_in_time` was called incorrectly for any translation requested before `after_setup_theme`, so every admin request on a site with a language pack for the domain logged the notice. Module_Registry::get_definitions() now carries structure only. Labels moved to get_labels()/get_label(), and Module_Controller resolves the list lazily on first use, which is `admin_menu` at the earliest. A frontend request no longer builds 38 translated strings just to decide which modules to load. The registry worker fixture now records the hook phase of every translation, and ModuleRegistryTest asserts no request translates before after_setup_theme. Also in this release: - DataViews 22.1.0, with a webpack config that bundles the two helper packages WordPress 7.0 and 7.1 do not register as scripts. - The WordPress 7 workspace mounts after the page heading's own block instead of the heading's next sibling. - bin/make-pot.sh raises PHP's memory limit. The DataViews bundle pushed wp7-admin.js past a megabyte and wp-cli's JavaScript parser exhausted the 128M default, which broke the template freshness check in CI. - .distignore excludes webpack.config.js and /build. The latter is wp-scripts' output directory: it is gitignored, so a release built from a clean checkout never saw it, but a package assembled from a working tree shipped a second copy of the bundle. - build.sh requires the workspace asset file and both stylesheets so a release cannot ship the bundle without the styles it needs. - Tested up to WordPress 7.2.
…s for 1.7.1 functionalities.dev now 301s to gauravtiwari.org, so every link in the plugin went through a redirect: the docs pages to /docs/functionalities/<section>/<page>/ and the site root, module list, downloads and FAQ to the product page and its anchors. All 34 references now name the destination directly, verified 200 each. That covers readme.txt, README.md, the `Plugin URI` header and the dashboard footer link, whose visible text said functionalities.dev. readme.txt gains a "New in 1.7.1" section, and its changelog entry is rewritten for readers rather than naming internal methods: it now also covers the workspace loading and placement fixes, which users can see. The supported versions answer and the upgrade notice name 7.2. README.md gains a short what's-new block. Its example module definition still showed titles inside get_definitions(), which is exactly the shape that caused the early-translation notice, so it now shows get_definitions() with get_labels() alongside and says why they are separate.
WordPress 7.2 rebuilt the block parser on top of a new WP_Block_Processor class, so WP_Block_Parser::parse() instantiates it. The bootstrap requires core's block-parser files by hand and did not know about the new one, so every test that reached parse_blocks() died with `Class "WP_Block_Processor" not found` on the WordPress trunk matrix legs. That accounted for 13 errors and both reported failures: the `expected size 5` assertion in UtilityModulesTest was downstream of the fatal in a worker, not a separate problem. The loader's existing file_exists guard means WordPress 6.3 through 7.1, which do not ship the file, are unaffected. Verified against a trunk sparse checkout (181 tests pass, previously 13 errors and 2 failures), against WordPress 7.1.5, and with no checkout at all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Module_Controller::init()built the admin module list onplugins_loaded, and the titles and descriptions in that list are translated. WordPress 6.7 and newer report_load_textdomain_just_in_timewas called incorrectly for any translation requested beforeafter_setup_theme, so every admin request on a site with a language pack for thefunctionalitiesdomain logged the notice.Two changes were needed, because fixing either alone leaves the bug alive:
Module_Registry::get_definitions()now carries structure only — icon, class, option, filter, controller. Labels moved to newget_labels()/get_label()methods that translate on demand.Module_Controllerresolves the list lazily through amodules()accessor instead of an eagerdefine_modules()call. All four read sites run atadmin_menuor later.get_admin_modules()still translates, so step 1 on its own left all 38 strings leaking — the worker fixture caught that.A frontend request no longer builds 38 translated strings just to decide which modules to load.
Why a reviewer should trust it
The registry worker fixture now records the hook phase of every
__()call, andModuleRegistryTest::test_no_translations_run_before_after_setup_themeasserts zero early translations across frontend, admin, and current-version requests.It was also verified against a live site running WordPress 7.1.5, using a probe that forces admin context, points the domain at a real directory through
lang_dir_for_domain, and hooksdoing_it_wrong_run:after_setup_themeThe 1.7.0 run reproduced the reported notice verbatim.
Also in this release
webpack.config.jsthat bundles@wordpress/kebab-caseand@wordpress/react-inert-valueinstead of leaving them external. WordPress 7.0 and 7.1 do not register them as scripts, so externalised the workspace would depend on handles that never load. Confirmed on WordPress 7.1.5: all 17 declared dependencies are registered and neither helper appears in the dependency list.mountWorkspace()climbs from theh1to the block that is a direct child of the target, rather than taking the heading's next sibling, because the page heading now sits inside a header block.bin/make-pot.shraises PHP's memory limit to 512M. The DataViews bundle pushedwp7-admin.jspast a megabyte and wp-cli's JavaScript parser exhausted the 128M default, which broke the template freshness check in CI. The limit is set inside the one shared script so the two sides cannot drift. The regenerated template has zero msgid changes — only line references..distignorenow excludeswebpack.config.jsand/build. The latter is wp-scripts' output directory: it is gitignored, so a release built from a clean checkout never saw it, but a package assembled from a working tree shipped a second copy of the bundle.build.shnow also requires the workspace asset file and both stylesheets, so a release cannot ship the bundle without the styles it needs — the same silent-404 shape as the earlier Prism incident.Verification
composer check— PHP lint on 63 files, phpcs 54/54, PHPUnit 181 testsnpm test— 19 testsbin/make-pot.sh --check— template currentnode --checkon every file underassets/Notes
The DOM anchor in
mountWorkspace()has not been exercised in a browser; everything around it was checked server-side.Documentation links and readme refresh (second commit)
functionalities.devnow 301s togauravtiwari.org, so every documentation link in the plugin went through a redirect. All 34 references now name the destination directly, each verified to return 200:gauravtiwari.org/docs/functionalities/<section>/<page>/That includes the
Plugin URIheader and the dashboard footer link, whose visible text also readfunctionalities.dev. The translation template was regenerated because thePlugin URImsgid changed.readme.txtgains a New in 1.7.1 section, and the changelog entry is rewritten for readers instead of naming internal methods — it now also covers the workspace loading and placement fixes, which are the parts users can actually see. The supported-versions answer and upgrade notice name 7.2.README.mdgains a short what's-new block. Its example module definition still showed titles insideget_definitions()— exactly the shape that caused this release's bug — so it now showsget_definitions()andget_labels()side by side with a note on why they are separate.