Skip to content

Namespace restriction for source= queries is inert: smwAskParserFunction/smwShowParserFunction hooks do not exist #45

@alistair3149

Description

@alistair3149

Summary

HookRegistry registers handlers for two hook names — smwAskParserFunction and smwShowParserFunction — that do not exist in Semantic MediaWiki. As a result, the feature they implement (restricting source= queries to $seqlgExternalQueryEnabledNamespaces) never runs.

Details

src/HookRegistry.php registers a handler under both names:

$this->handlers['smwAskParserFunction'] = $this->handlers['smwShowParserFunction'] = static function ( $parser, $frame, $args, &$override ) {
    // ... sets:
    //   $override = 'Warning: source parameter is not allowed in the namespace!'
    // when the page's namespace is not in $GLOBALS['seqlgExternalQueryEnabledNamespaces']
};

This only does anything if Semantic MediaWiki fires hooks literally named smwAskParserFunction / smwShowParserFunction. Those names appear nowhere in the Semantic MediaWiki source tree, nor anywhere in its Git history, so the handlers are never invoked. The #ask / #show execution path (AskParserFunction / ShowParserFunction) does not run a hook of that name.

Impact

The $seqlgExternalQueryEnabledNamespaces namespace restriction is silently inert: a {{#ask: … |source=… }} (or {{#show:}}) query is not blocked in disallowed namespaces, contrary to what the setting documents.

This is pre-existing (identical on the current released code and on the SMW 7.0 branch) and was discovered during the SMW 7.0 migration (#44). The test suite does not catch it because HookRegistryTest only asserts the InterwikiLoadPrefix handler is registered, not that the ask/show guard fires.

Suggested next steps

  • Confirm whether Semantic MediaWiki exposes an equivalent hook in a supported version that allows inspecting/overriding #ask / #show parser-function invocations, and rewire the namespace guard to it; or
  • If no such hook exists, remove the dead handlers and either implement the namespace restriction by another mechanism or update the $seqlgExternalQueryEnabledNamespaces documentation accordingly.
  • Add test coverage for whichever path is chosen so the guard cannot silently regress again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions