Repository navigation
Conversation
Since 1.7.0 action=query sub-modules are matched against $wgCrawlerProtectedApiModules, so protecting 'revisions' broke Page Previews (Popups) for anonymous readers: its preview request includes prop=revisions&rvprop=timestamp for a single title. Add $wgCrawlerProtectionAllowRevisionMetadata (default true). When set, an anonymous action=query request is not denied on account of 'revisions' if it is the only protected module, the request names exactly one page via titles or pageids (no generator, no revids), rvprop is given explicitly and contains only 'timestamp', and no other rv* parameter is present. The CrawlerProtectionShouldDeny hook still receives the final decision. The multi-value separator logic is factored out into CrawlerProtectionService::splitApiMultiValue() and shared with Hooks::getApiModuleNames(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dk5bcSgoy2euC39AzvNmnV
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.
Summary
This change adds a new configuration option
$wgCrawlerProtectionAllowRevisionMetadatathat exempts specific API queries from crawler protection. When enabled (default), anonymous users can request revision timestamps for single pages, which is necessary for Page Previews (Popups) to function properly while still protecting the revisions module from broader access.Key Changes
New configuration option:
$wgCrawlerProtectionAllowRevisionMetadata(defaults totrue)action=queryrequests that only ask for revision timestamps of a single pageNew method
isRevisionMetadataQuery(): Validates that a query request qualifies for the exemption by checking:revisionsmodule is protected in the requesttitlesorpageids, notgeneratororrevids)rvpropparameter contains onlytimestamprv*parameters are presentNew utility method
splitApiMultiValue(): Handles both pipe-separated (|) and unit-separator (\x1f) forms of multi-value API parameters, matching MediaWiki's API behaviorIntegration with existing logic: The exemption is applied in
checkApiModules()after determining the request would normally be denied, but before theCrawlerProtectionShouldDenyhook, allowing hooks to still override the decisionNotable Implementation Details
CrawlerProtectionShouldDenyhook receives the final decision after the exemption is appliedhttps://claude.ai/code/session_01Dk5bcSgoy2euC39AzvNmnV