Skip to content
Open
Changes from all commits
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
35 changes: 35 additions & 0 deletions includes/Compat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace MediaWiki\Extension\CrawlerProtection;

class Compat {
Comment on lines +1 to +5
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

This new file is missing the standard file header used elsewhere in this extension (license block + @file tag). Keeping headers consistent helps with licensing compliance and makes files easier to audit.

Copilot uses AI. Check for mistakes.

public static function init(): void {
self::aliasCoreClasses();
}

private static function aliasCoreClasses(): void {

Comment on lines +7 to +12
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

Compat::init() is never called (no references found in the repo, and extension.json doesn’t register a callback), so the class aliases in this file currently never take effect. Either wire this up to run during extension registration (early enough to affect any use/autoloading) or remove the unused compat layer to avoid misleading future maintainers.

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +12
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

Indentation is inconsistent with the MediaWiki convention used in the rest of this extension (tabs for indentation). This file mixes spaces and tabs (e.g., method bodies and closing braces), which will cause avoidable style diffs and can trip PHPCS.

Copilot uses AI. Check for mistakes.
if ( class_exists( \Title::class ) && !class_exists( \MediaWiki\Title\Title::class ) ) {
class_alias( \Title::class, \MediaWiki\Title\Title::class ); /* < 1.40 */
}
if ( class_exists( \OutputPage::class ) && !class_exists( \MediaWiki\Output\OutputPage::class ) ) {
class_alias( \OutputPage::class, \MediaWiki\Output\OutputPage::class ); /* < 1.41 */
}
if ( class_exists( \WebRequest::class ) && !class_exists( \MediaWiki\Request\WebRequest::class ) ) {
class_alias( \WebRequest::class, \MediaWiki\Request\WebRequest::class ); /* < 1.41 */
}
if ( class_exists( \SpecialPage::class ) && !class_exists( \MediaWiki\SpecialPage\SpecialPage::class ) ) {
class_alias( \SpecialPage::class, \MediaWiki\SpecialPage\SpecialPage::class ); /* < 1.41 */
}
if ( class_exists( \User::class ) && !class_exists( \MediaWiki\User\User::class ) ) {
class_alias( \User::class, \MediaWiki\User\User::class ); /* < 1.41 */
}
if ( class_exists( \ActionEntryPoint::class ) && !class_exists( \MediaWiki\Actions\ActionEntryPoint::class ) ) {
class_alias( \ActionEntryPoint::class, \MediaWiki\Actions\ActionEntryPoint::class ); /* < 1.42 */
Comment on lines +28 to +29
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

ActionEntryPoint aliasing here appears to target the wrong legacy class. The existing compat logic in this extension aliases \\MediaWiki to \\MediaWiki\\Actions\\ActionEntryPoint for older MediaWiki versions; using \\ActionEntryPoint as the source class likely won’t work on those versions (the class may not exist). Align the alias source/target with the actual legacy class name used by core.

Suggested change
if ( class_exists( \ActionEntryPoint::class ) && !class_exists( \MediaWiki\Actions\ActionEntryPoint::class ) ) {
class_alias( \ActionEntryPoint::class, \MediaWiki\Actions\ActionEntryPoint::class ); /* < 1.42 */
if ( class_exists( \MediaWiki::class ) && !class_exists( \MediaWiki\Actions\ActionEntryPoint::class ) ) {
class_alias( \MediaWiki::class, \MediaWiki\Actions\ActionEntryPoint::class ); /* < 1.42 */

Copilot uses AI. Check for mistakes.
}
if ( class_exists( \Article::class ) && !class_exists( \MediaWiki\Page\Article::class ) ) {
class_alias( \Article::class, \MediaWiki\Page\Article::class ); /* < 1.42 */
}
}
}
Loading