Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions includes/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,19 @@ protected function denyAccessRaw( string $header, string $message ): void {
* @return void
*/
protected function denyAccessPretty( $output ): void {
$output->clearHTML();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of adding this at the beginning of the page? It's currently unclear what this does, but if there's a good reason for it, an explanatory comment would be much appreciated.

$output->setStatusCode( 403 );
Comment on lines 116 to 117
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New calls to OutputPage::clearHTML() (and later returnToMain()) will break the unit-test environment that relies on tests/phpunit/namespaced-stubs.php: its OutputPage stub doesn’t define these methods, so createMock() will fail. Update the stub to include clearHTML() and returnToMain(), and (optionally) add expectations in ResponseFactoryTest so the behavior is covered.

Copilot uses AI. Check for mistakes.
$output->addWikiTextAsInterface(
wfMessage( 'crawlerprotection-accessdenied-text' )->plain()
);

if ( version_compare( MW_VERSION, '1.41', '<' ) ) {
$output->setPageTitle( wfMessage( 'crawlerprotection-accessdenied-title' ) );
} else {
// @phan-suppress-next-line PhanUndeclaredMethod Exists in 1.41+
$output->setPageTitleMsg( wfMessage( 'crawlerprotection-accessdenied-title' ) );
}

$output->addWikiTextAsInterface(
wfMessage( 'crawlerprotection-accessdenied-text' )->plain()
);
$output->returnToMain();
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OutputPage::returnToMain() is now part of the denyAccessPretty flow, but ResponseFactoryTest currently only asserts setStatusCode/addWikiTextAsInterface; consider extending the test to assert returnToMain() is called so this new 403-page behavior is exercised (and to prevent regressions).

Copilot uses AI. Check for mistakes.
}
}
Loading