Skip to content

Fall back to default settings when page config is missing - #81

Merged
jmnote merged 2 commits into
mainfrom
js-config-defaults
Oct 8, 2026
Merged

jmnote merged 2 commits into
mainfrom
js-config-defaults

Conversation

@jmnote

@jmnote jmnote commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Problem

After upgrading from 0.9.x to 1.1.0, pages served from a cache populated before the upgrade (CDN or reverse proxy) still carry the old wgSmj* names in RLCONF, while ext.SimpleMathJax comes from the new version. mw.config.get('wgSmjDelimitersInlineMath') is then null, ensureLoaded() throws Cannot read properties of null (reading 'concat'), and no formula on the page renders until the cached HTML expires.

Change

  • resources/ext.SimpleMathJax.js: read settings through config(name), which falls back to a defaults object matching extension.json when the page does not provide a value. All 10 wgSmj* reads go through it. wgSmjEnableMenu is exported but not read by the client, so it has no client default.
  • Settings that 1.0 only renamed fall back to their pre-1.0 name first (wgSmjUseCdn → wgSmjCdnEnabled), so a cached page from a site with the CDN disabled still loads the bundled MathJax. Settings whose meaning changed in 1.0 (delimiters) are not mapped.
  • tests/JsDefaultsTest.php (added to make test): every config('wgSmj…') read has a default, each default equals the extension.json value, and each legacy mapping is listed as a rename in docs/mig-1.0.md.

Tests

  • make checks passes. The new test fails when a default is changed (checked with wgSmjScale: 2).
  • Browser, MediaWiki 1.43 with the page's wgSmj* removed from RLCONF to simulate cached HTML: before, the error above and 0 formulas; after, no error and all 84 formulas rendered with MathJax 4.1.3.
  • Same with a pre-1.0 config wgSmjUseCdn: false: MathJax is requested from extensions/SimpleMathJax/resources/MathJax/tex-chtml.js instead of jsDelivr.

The page HTML that carries the wgSmj* settings can be cached separately
from the ext.SimpleMathJax module (CDN or reverse proxy). Right after an
upgrade that renamed settings (1.0), a cached page paired with the new
module left wgSmjDelimitersInlineMath null, so ensureLoaded() threw on
.concat and no formula rendered. Read settings through a helper that
falls back to the extension.json defaults, and test that the two stay in
sync.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T14:50:24.263869Z 2b3ac9f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2b3ac9fcbb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread resources/ext.SimpleMathJax.js Outdated

function config(name) {
var value = mw.config.get(name);
return value === null || value === undefined ? defaults[name] : value;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the cached legacy CDN setting

On the pre-1.0 cached pages this change targets, wgSmjCdnEnabled is absent but its renamed predecessor wgSmjUseCdn is present. For installations that set the legacy value to false, this unconditional default returns true and loads MathJax from jsDelivr instead of the bundled copy; sites that disabled CDN access for CSP, privacy, or network reasons will therefore still render no formulas until the HTML cache expires. Consult wgSmjUseCdn before falling back to the default for this renamed setting.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. config() now consults the pre-1.0 name for settings that were only renamed (wgSmjUseCdn → wgSmjCdnEnabled, per the "Renamed only" table in docs/mig-1.0.md) before falling back to the default. Settings whose meaning or default changed in 1.0 (wgSmjDirectMathJax etc.) are deliberately not mapped, so cached pages behave like freshly rendered ones. tests/JsDefaultsTest.php checks that each legacy mapping is listed as a rename in the guide. Browser check with a pre-1.0 page config (wgSmjUseCdn: false): MathJax is requested from extensions/SimpleMathJax/resources/MathJax/tex-chtml.js instead of jsDelivr.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reconsidered: 1.0 deliberately dropped pre-1.0 setting names (docs/mig-1.0.md), so the client should not read wgSmjUseCdn either. Removed in #83; only the fallback to extension.json defaults remains.

wgSmjCdnEnabled is a pure rename of wgSmjUseCdn. A cached pre-1.0 page
carries only the old name, so a site with the CDN disabled would load
MathJax from jsDelivr. Settings whose meaning changed in 1.0 (delimiters)
are deliberately not mapped.
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Oct 8, 2026
@jmnote
jmnote merged commit 45f4d9c into main Oct 8, 2026
1 check passed
@jmnote
jmnote deleted the js-config-defaults branch October 8, 2026 15:03
jmnote added a commit to zetaoss/zengine that referenced this pull request Oct 8, 2026
Falls back to extension.json defaults when the page config lacks the
wgSmj* settings, e.g. HTML cached before an upgrade (jmnote/SimpleMathJax#81).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant