Skip to content

Move extension registration into extension.json#113

Merged
paladox merged 1 commit into
masterfrom
migrate-extension-registration
Jun 4, 2026
Merged

Move extension registration into extension.json#113
paladox merged 1 commit into
masterfrom
migrate-extension-registration

Conversation

@alistair3149

Copy link
Copy Markdown
Member

Moves the extension's registration out of the procedural root SemanticMetaTags.php entry point into native extension.json declarations, so the extension no longer keeps a root PHP file or a callback.

Changes

  • Settings → config. The five smtg* settings defaults move from DefaultSettings.php into the extension.json config section with config_prefix: smtg. The global names (smtgTagsProperties, smtgTagsStrings, smtgTagsBlacklist, smtgTagsPropertyFallbackUsage, smtgMetaPropertyPrefixes) and their default values are unchanged, so existing LocalSettings.php overrides keep working. DefaultSettings.php is deleted. Using config rather than a callback matters: a callback runs after LocalSettings.php and would overwrite user overrides, whereas config values are true defaults the user wins over.
  • Extension function → namespaced class. onExtensionFunction moves into a new SMT\Setup class, and ExtensionFunctions points at SMT\Setup::onExtensionFunction. The two runtime hooks it builds (OutputPageParserOutput, BeforePageDisplay) need the store and options, so they stay registered from the extension function.
  • Removed dead/redundant code. Drops the callback, AutoloadClasses, the SMT_VERSION constant, the never-wired doCheckRequirements() method, and the !defined( 'SMW_VERSION' ) die guard (unreachable now that requires.extensions.SemanticMediaWiki gates loading). The message directory is already declared via MessagesDirs.
  • Tests. tests/bootstrap.php reads the version from extension.json instead of the removed SMT_VERSION constant. I18nJsonFileIntegrityTest is guarded against wgMessagesDirs now resolving to the manifest array rather than the string the removed procedural assignment used to set.
  • Deletes the root SemanticMetaTags.php.

Verification

  • composer analyze clean (lint + PHPCS + minus-x) and composer phpunit green (80 tests) in the docker-compose-ci stack on MediaWiki 1.43 + SMW dev-master.
  • Live page-view smoke test: with a static-string tag and a property-backed tag configured, both <meta> elements are injected into the real page HTML, confirming the migrated extension function and hook registration drive the render path end to end.
  • Confirmed via eval.php that the config_prefix defaults populate the smtg* globals, the runtime hooks register, the old SemanticMetaTags class is gone, and SMT\Setup is present.

Replace the procedural registration in the root SemanticMetaTags.php
entry point with native extension.json declarations:

- Move the five smtg* settings defaults from DefaultSettings.php into the
  extension.json `config` section with `config_prefix: smtg`; the global
  names and default values are unchanged. Delete DefaultSettings.php.
- Move the extension function into a namespaced SMT\Setup class and point
  ExtensionFunctions at SMT\Setup::onExtensionFunction. Drop the
  !defined( 'SMW_VERSION' ) die guard, which is unreachable now that
  requires.extensions.SemanticMediaWiki gates loading.
- Remove the callback, AutoloadClasses, the dead doCheckRequirements()
  method, and the SMT_VERSION constant. The messages directory is already
  declared via MessagesDirs.
- Read the version from extension.json in tests/bootstrap.php instead of
  the removed SMT_VERSION constant.
- Guard I18nJsonFileIntegrityTest against wgMessagesDirs now resolving to
  an array (the manifest value) rather than the string the removed
  procedural assignment used to set.

Delete the root SemanticMetaTags.php entry-point class.
@alistair3149 alistair3149 requested a review from paladox June 4, 2026 18:40
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.88%. Comparing base (2eecb7d) to head (ace2aa8).

Files with missing lines Patch % Lines
src/Setup.php 0.00% 12 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #113      +/-   ##
============================================
- Coverage     82.43%   77.88%   -4.56%     
- Complexity       80       81       +1     
============================================
  Files             7        8       +1     
  Lines           205      217      +12     
============================================
  Hits            169      169              
- Misses           36       48      +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alistair3149 alistair3149 marked this pull request as ready for review June 4, 2026 18:40
@paladox paladox merged commit a1665b4 into master Jun 4, 2026
4 of 10 checks passed
@paladox paladox deleted the migrate-extension-registration branch June 4, 2026 18:43
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