diff --git a/includes/ResponseFactory.php b/includes/ResponseFactory.php index 9da0abb..6431638 100644 --- a/includes/ResponseFactory.php +++ b/includes/ResponseFactory.php @@ -77,7 +77,10 @@ public function __construct( ServiceOptions $options ) { public function denyAccess( $output ): void { if ( $this->options->get( 'CrawlerProtectionRawDenial' ) ) { if ( $this->options->get( 'CrawlerProtectionUse418' ) ) { - $this->denyAccessWith418(); + $this->denyAccessRaw( + self::TEAPOT_HEADER, + self::TEAPOT_BODY + ); } else { $this->denyAccessRaw( $this->options->get( 'CrawlerProtectionRawDenialHeader' ), @@ -85,20 +88,12 @@ public function denyAccess( $output ): void { ); } } else { + $output->clearHTML(); $this->denyAccessPretty( $output ); + $output->returnToMain(); } } - /** - * Output a 418 "I'm a teapot" response and halt. - * - * @return void - * @suppress PhanPluginNeverReturnMethod - */ - protected function denyAccessWith418(): void { - $this->denyAccessRaw( self::TEAPOT_HEADER, self::TEAPOT_BODY ); - } - /** * Output a raw HTTP response and halt. * @@ -120,9 +115,6 @@ protected function denyAccessRaw( string $header, string $message ): void { */ protected function denyAccessPretty( $output ): void { $output->setStatusCode( 403 ); - $output->addWikiTextAsInterface( - wfMessage( 'crawlerprotection-accessdenied-text' )->plain() - ); if ( version_compare( MW_VERSION, '1.41', '<' ) ) { $output->setPageTitle( wfMessage( 'crawlerprotection-accessdenied-title' ) ); @@ -130,5 +122,9 @@ protected function denyAccessPretty( $output ): void { // @phan-suppress-next-line PhanUndeclaredMethod Exists in 1.41+ $output->setPageTitleMsg( wfMessage( 'crawlerprotection-accessdenied-title' ) ); } + + $output->addWikiTextAsInterface( + wfMessage( 'crawlerprotection-accessdenied-text' )->plain() + ); } }