Skip to content

Replace the bootstrap file with declarative registration#94

Merged
paladox merged 3 commits into
masterfrom
deprecate-bootstrap-file
Jun 3, 2026
Merged

Replace the bootstrap file with declarative registration#94
paladox merged 3 commits into
masterfrom
deprecate-bootstrap-file

Conversation

@alistair3149

Copy link
Copy Markdown
Member

Summary

Removes the root SemanticCompoundQueries.php bootstrap and registers everything it did declaratively in extension.json. The only piece that cannot be declarative — the #compound_query parser function — moves into a small SCQ\Hooks ParserFirstCallInit handler (MediaWiki has no declarative parser-function registration).

Moved into extension.json

  • The i18n magic-words file → ExtensionMessagesFiles
  • The compoundquery API module (with the SMW.QuerySourceFactory service) → APIModules
  • The #compound_query parser function → HookHandlers + Hooks (handled by the new SCQ\Hooks)

Removed

  • SemanticCompoundQueries.php and the SemanticCompoundQueries class
  • callback, ExtensionFunctions, and AutoloadClasses from extension.json
  • load_composer_autoloader and the composer autoload block — the extension has no runtime composer dependencies (require is only php plus the install-time composer/installers), so vendor/autoload.php is never needed at runtime; SCQ\ is autoloaded via AutoloadNamespaces
  • The SCQ_VERSION constant and its two consumers: a dead CompoundQuery::getVersion() override (it overrode ApiBase::getVersion(), removed from MediaWiki core long ago) and a version line in the PHPUnit bootstrap (now read from extension.json)
  • The runtime !defined( 'SMW_VERSION' ) guard — requires.extensions.SemanticMediaWiki already enforces SMW's presence at registration

Test fix included

I18nJsonFileIntegrityTest now handles the canonical array form of wgMessagesDirs['SemanticCompoundQueries']. The old bootstrap overwrote MediaWiki's array (built from MessagesDirs) with a bare string, which the test relied on; removing the bootstrap restores the array, so the test reads the first directory entry.

No user-facing change: #compound_query and the compoundquery API module register with identical names and behaviour. The removed class and constant are internal-only and undocumented, and 7.0.0 is unreleased.

Test plan

  • composer analyze — clean (lint + PHPCS + minus-x)
  • composer test — green (63 tests, 121 assertions), including a new HooksTest and CompoundQueryTest::testExecute (which issues an action=compoundquery request, exercising the API-module registration)
  • Manual smoke test on a dev wiki: Special:Version lists the extension at 7.0.0-alpha; {{#compound_query:…}} renders a result table; action=compoundquery returns results; the compound_query magic word resolves

🤖 Generated with Claude Code

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.56%. Comparing base (6932a8d) to head (ba6bec9).

Files with missing lines Patch % Lines
src/Hooks.php 0.00% 2 Missing ⚠️

❌ Your project check has failed because the head coverage (29.56%) is below the adjusted base coverage (30.08%). You can increase the head coverage or adjust the Removed Code Behavior.

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #94      +/-   ##
============================================
- Coverage     30.08%   29.56%   -0.53%     
- Complexity       40       41       +1     
============================================
  Files             3        4       +1     
  Lines           113      115       +2     
============================================
  Hits             34       34              
- Misses           79       81       +2     

☔ View full report in Codecov by Sentry.
📢 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 3, 2026 00:17
Drop the dead ApiBase::getVersion override (the parent method no longer
exists in MediaWiki core) and read the test-run version header from
extension.json instead of the SCQ_VERSION constant, so the constant can
be removed with the bootstrap file.
Move message files, the compoundquery API module, and the
#compound_query parser-function hook into extension.json. The parser
function is registered by a new SCQ\Hooks ParserFirstCallInit handler.
Delete SemanticCompoundQueries.php and drop load_composer_autoloader and
the composer autoload block; the extension has no runtime composer
dependencies and autoloads SCQ\ via AutoloadNamespaces.

Fix I18nJsonFileIntegrityTest to handle the canonical array form of
wgMessagesDirs['SemanticCompoundQueries'] set by MW from extension.json
(the old bootstrap overwrote it with a string, masking this).
Mirror the existing SMW-autoloader is_readable() guard so a missing or
unreadable extension.json fails with a clear message instead of a
TypeError when reading the version.
@alistair3149 alistair3149 force-pushed the deprecate-bootstrap-file branch from b87f937 to ba6bec9 Compare June 3, 2026 00:27
@alistair3149 alistair3149 requested a review from paladox June 3, 2026 00:29
@paladox paladox merged commit 292f793 into master Jun 3, 2026
7 checks passed
@paladox paladox deleted the deprecate-bootstrap-file branch June 3, 2026 00:33
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