Skip to content

fix(styles): list built-in styles from theme config.xml files - #145

Merged
erseco merged 5 commits into
mainfrom
hotfix/builtin-styles-compressed-bundle
Sep 26, 2026
Merged

erseco merged 5 commits into
mainfrom
hotfix/builtin-styles-compressed-bundle

Conversation

@erseco

@erseco erseco commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Thanks to @ismagago for reporting this.

Fixes exelearning/exelearning#2461 for the WordPress plugin.

Problem

ExeLearning_Styles_Service::list_builtin_themes() read the theme list from dist/static/data/bundle.json. Current editor builds ship only the zstd-compressed data/bundle.json.zst, which PHP cannot decode without the rarely installed zstd extension. The v4.0.5 ZIP has no plain bundle.json, so the settings screen showed no built-in styles and administrators could not hide any. The tests did not catch this because the fixture wrote a plain bundle.json.

Fix

  • list_builtin_themes() now reads each dist/static/files/perm/themes/base/<dir>/config.xml. It reuses the existing hardened ExeLearning_Style_Package::parse_config_xml() and uses the directory name as the theme id. Themes with a missing, empty or corrupt config.xml are skipped.
  • The bundle.json walker (extract_themes_from_bundle() in both classes) had no other callers, so it has been removed along with its tests.
  • ExeLearning_Bundle_Fixture now builds the same layout as a release: a config.xml per theme and only bundle.json.zst.

Verification

  • TDD: with the updated fixture, StylesServiceBuiltinsTest failed on main (4 failures, all empty lists) and passes with the fix.
  • Styles, bundle, settings and bootstrap tests: 197 tests OK.
  • Full suite: 936 tests. The 3 failures in BlockTranslationsTest/I18nTest also fail on main locally, because the compiled translation files are missing and are unrelated to this change.
  • vendor/bin/phpcs is clean on the changed files.

Editor builds now ship only data/bundle.json.zst, so reading the plain
bundle.json returned no built-in styles. Read each bundled theme's
config.xml instead and drop the unused bundle.json walker.
@erseco erseco added the bug Something isn't working label Sep 26, 2026
@erseco erseco self-assigned this Sep 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Test in WordPress Playground

Test the plugin with the code from this branch:

Preview in WordPress Playground

ℹ️ The eXeLearning editor is fetched from the shared release and unpacked into the plugin when the playground boots, so the first load may take a few extra seconds. ELP upload, shortcode, Gutenberg block and preview work normally.

@codecov-commenter

codecov-commenter commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.39%. Comparing base (6710a4b) to head (fbbd504).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #145      +/-   ##
============================================
- Coverage     96.40%   96.39%   -0.02%     
+ Complexity      827      815      -12     
============================================
  Files            36       36              
  Lines          4228     4213      -15     
============================================
- Hits           4076     4061      -15     
  Misses          152      152              
Flag Coverage Δ
javascript 95.71% <ø> (ø)
php 96.61% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
includes/class-style-package.php 95.65% <ø> (-0.42%) ⬇️
includes/class-styles-service.php 96.68% <100.00%> (+0.09%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…-compressed-bundle

# Conflicts:
#	languages/exelearning-ca.po
#	languages/exelearning-ca_valencia.po
#	languages/exelearning-de_DE.po
#	languages/exelearning-eo.po
#	languages/exelearning-es_ES.po
#	languages/exelearning-eu.po
#	languages/exelearning-gl_ES.po
#	languages/exelearning-it_IT.po
#	languages/exelearning-pt_PT.po
#	languages/exelearning-ro_RO.po
#	languages/exelearning.pot
@erseco
erseco merged commit 8aed260 into main Sep 26, 2026
5 checks passed
@erseco
erseco deleted the hotfix/builtin-styles-compressed-bundle branch September 26, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Moodle: built-in styles reported as unavailable because the plugin cannot read the compressed bundle.json.zst

2 participants