Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#45 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
php
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu trong src/HookRegistry.php và kiểm tra các handler smwAskParserFunction và smwShowParserFunction đã đăng ký. Kiểm tra xem một hook được Semantic MediaWiki hỗ trợ có thể kiểm tra hoặc ghi đè các lệnh gọi #ask và #show hay không, sau đó xem lại HookRegistryTest.php. Công việc được xem là hoàn tất khi giới hạn namespace hoạt động thông qua một đường dẫn được hỗ trợ, hoặc các handler không còn được sử dụng và tài liệu được cập nhật, cùng với phạm vi kiểm thử hồi quy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
PHP
Star
9
Fork
8
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của SemanticMediaWiki/SemanticExternalQueryLookup

Tất cả issue của SemanticMediaWiki/SemanticExternalQueryLookup

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.