Move extension registration into extension.json#113
Merged
Conversation
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.
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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.
Moves the extension's registration out of the procedural root
SemanticMetaTags.phpentry point into nativeextension.jsondeclarations, so the extension no longer keeps a root PHP file or acallback.Changes
config. The fivesmtg*settings defaults move fromDefaultSettings.phpinto theextension.jsonconfigsection withconfig_prefix: smtg. The global names (smtgTagsProperties,smtgTagsStrings,smtgTagsBlacklist,smtgTagsPropertyFallbackUsage,smtgMetaPropertyPrefixes) and their default values are unchanged, so existingLocalSettings.phpoverrides keep working.DefaultSettings.phpis deleted. Usingconfigrather than acallbackmatters: acallbackruns afterLocalSettings.phpand would overwrite user overrides, whereasconfigvalues are true defaults the user wins over.onExtensionFunctionmoves into a newSMT\Setupclass, andExtensionFunctionspoints atSMT\Setup::onExtensionFunction. The two runtime hooks it builds (OutputPageParserOutput,BeforePageDisplay) need the store and options, so they stay registered from the extension function.callback,AutoloadClasses, theSMT_VERSIONconstant, the never-wireddoCheckRequirements()method, and the!defined( 'SMW_VERSION' )die guard (unreachable now thatrequires.extensions.SemanticMediaWikigates loading). The message directory is already declared viaMessagesDirs.tests/bootstrap.phpreads the version fromextension.jsoninstead of the removedSMT_VERSIONconstant.I18nJsonFileIntegrityTestis guarded againstwgMessagesDirsnow resolving to the manifest array rather than the string the removed procedural assignment used to set.SemanticMetaTags.php.Verification
composer analyzeclean (lint + PHPCS + minus-x) andcomposer phpunitgreen (80 tests) in the docker-compose-ci stack on MediaWiki 1.43 + SMWdev-master.<meta>elements are injected into the real page HTML, confirming the migrated extension function and hook registration drive the render path end to end.eval.phpthat theconfig_prefixdefaults populate thesmtg*globals, the runtime hooks register, the oldSemanticMetaTagsclass is gone, andSMT\Setupis present.