aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--RELEASE-NOTES-1.373
-rw-r--r--includes/DefaultSettings.php2
-rw-r--r--includes/GlobalFunctions.php6
-rw-r--r--includes/Hook/BeforeHttpsRedirectHook.php29
-rw-r--r--includes/Hook/CanIPUseHTTPSHook.php26
-rw-r--r--includes/HookContainer/DeprecatedHooks.php3
-rw-r--r--includes/HookContainer/HookRunner.php24
-rw-r--r--includes/MediaWiki.php5
-rw-r--r--includes/user/Hook/UserRequiresHTTPSHook.php28
-rw-r--r--includes/user/User.php1
-rw-r--r--tests/phpunit/includes/user/UserTest.php26
11 files changed, 11 insertions, 142 deletions
diff --git a/RELEASE-NOTES-1.37 b/RELEASE-NOTES-1.37
index fc174c921660..5a325bc96529 100644
--- a/RELEASE-NOTES-1.37
+++ b/RELEASE-NOTES-1.37
@@ -119,6 +119,8 @@ because of Phabricator reports.
UserGroupManager instead.
* The following classes, hard-deprecated since 1.36, have been removed:
CachedAction, SpecialCachedPage, CacheHelper, ICacheHelper.
+* The hooks BeforeHttpsRedirect, CanIPUseHTTPS and UserRequiresHTTPS, deprecated
+ in 1.35, were removed.
* The deprecated "es6-promise" alias ResourceLoader module has been removed. Use
"es6-polyfills" directly intead.
* AuthenticationProvider interface doesn't extend LoggerAwareInterface.
@@ -149,6 +151,7 @@ because of Phabricator reports.
* Title::isWatchable() has been deprecated. Use WatchlistManager::isWatchable()
instead.
* wfIncrStats(), deprecated in 1.36, now emits deprecation warnings.
+* wfCanIPUseHTTPS() is now deprecated, and always returns true.
* AbstractAuthenticationProvider ::setLogger(), ::setManager(), ::setConfig(),
::setHookContainer() were soft deprecated. Use ::init() to inject
dependencies or override ::postInitSetup() to do any custom
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 5553067b3099..f8d51a94c60a 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -147,7 +147,7 @@ $wgHttpsPort = 443;
/**
* If this is true, when an insecure HTTP request is received, always redirect
* to HTTPS. This overrides and disables the preferhttps user preference, and it
- * overrides $wgSecureLogin and the CanIPUseHTTPS hook.
+ * overrides $wgSecureLogin.
*
* $wgServer may be either https or protocol-relative. If $wgServer starts with
* "http://", an exception will be thrown.
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 76dc13ab8dba..f178e151f233 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -2750,13 +2750,13 @@ function wfUnpack( $format, $data, $length = false ) {
* Determine whether the client at a given source IP is likely to be able to
* access the wiki via HTTPS.
*
+ * @deprecated since 1.37, always returns true
+ *
* @param string $ip The IPv4/6 address in the normal human-readable form
* @return bool
*/
function wfCanIPUseHTTPS( $ip ) {
- $canDo = true;
- Hooks::runner()->onCanIPUseHTTPS( $ip, $canDo );
- return (bool)$canDo;
+ return true;
}
/**
diff --git a/includes/Hook/BeforeHttpsRedirectHook.php b/includes/Hook/BeforeHttpsRedirectHook.php
deleted file mode 100644
index 6a265bdc659c..000000000000
--- a/includes/Hook/BeforeHttpsRedirectHook.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace MediaWiki\Hook;
-
-use IContextSource;
-
-/**
- * This is a hook handler interface, see docs/Hooks.md.
- * Use the hook name "BeforeHttpsRedirect" to register handlers implementing this interface.
- *
- * @deprecated since 1.35
- * @ingroup Hooks
- */
-interface BeforeHttpsRedirectHook {
- /**
- * This hook is called prior to forcing HTTP->HTTPS redirect. Use this hook
- * to override how the redirect is output.
- * ATTENTION: This hook is likely to be removed soon due to overall design of the
- * system.
- *
- * @since 1.35
- *
- * @param IContextSource $context
- * @param string &$redirect string URL, modifiable
- * @return bool|void True or no return value to continue, or false to let standard HTTP rendering
- * take place
- */
- public function onBeforeHttpsRedirect( $context, &$redirect );
-}
diff --git a/includes/Hook/CanIPUseHTTPSHook.php b/includes/Hook/CanIPUseHTTPSHook.php
deleted file mode 100644
index 9bf4725b1779..000000000000
--- a/includes/Hook/CanIPUseHTTPSHook.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-
-namespace MediaWiki\Hook;
-
-/**
- * This is a hook handler interface, see docs/Hooks.md.
- * Use the hook name "CanIPUseHTTPS" to register handlers implementing this interface.
- *
- * @deprecated since 1.35
- * @ingroup Hooks
- */
-interface CanIPUseHTTPSHook {
- /**
- * Use this hook to determine whether the client at a given source IP is likely
- * to be able to access the wiki via HTTPS.
- *
- * @deprecated since 1.35 This feature will be removed. All clients should use HTTPS.
- *
- * @since 1.35
- *
- * @param string $ip IP address in human-readable form
- * @param bool &$canDo Set to false if the client may not be able to use HTTPS
- * @return bool|void True or no return value to continue or false to abort
- */
- public function onCanIPUseHTTPS( $ip, &$canDo );
-}
diff --git a/includes/HookContainer/DeprecatedHooks.php b/includes/HookContainer/DeprecatedHooks.php
index 916088e75c8a..e0e1e1b91e16 100644
--- a/includes/HookContainer/DeprecatedHooks.php
+++ b/includes/HookContainer/DeprecatedHooks.php
@@ -38,10 +38,8 @@ class DeprecatedHooks {
'ArticleEditUpdates' => [ 'deprecatedVersion' => '1.35' ],
'BaseTemplateAfterPortlet' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
'BaseTemplateToolbox' => [ 'deprecatedVersion' => '1.35' ],
- 'BeforeHttpsRedirect' => [ 'deprecatedVersion' => '1.35' ],
'BeforeParserFetchTemplateAndtitle' => [ 'deprecatedVersion' => '1.36' ],
'BeforeParserrenderImageGallery' => [ 'deprecatedVersion' => '1.35' ],
- 'CanIPUseHTTPS' => [ 'deprecatedVersion' => '1.35' ],
'EditPageBeforeEditToolbar' => [ 'deprecatedVersion' => '1.36' ],
'InternalParseBeforeSanitize' => [ 'deprecatedVersion' => '1.35' ],
'MagicWordwgVariableIDs' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
@@ -60,7 +58,6 @@ class DeprecatedHooks {
'SkinTemplateTabAction' => [ 'deprecatedVersion' => '1.35' ],
'SkinTemplateToolboxEnd' => [ 'deprecatedVersion' => '1.35' ],
'TitleArrayFromResult' => [ 'deprecatedVersion' => '1.36' ],
- 'UserRequiresHTTPS' => [ 'deprecatedVersion' => '1.35' ],
'UserRetrieveNewTalks' => [ 'deprecatedVersion' => '1.35' ],
'UserSetCookies' => [ 'deprecatedVersion' => '1.27' ],
'WikiPageDeletionUpdates' => [ 'deprecatedVersion' => '1.32', 'silent' => true ],
diff --git a/includes/HookContainer/HookRunner.php b/includes/HookContainer/HookRunner.php
index f1b6d0d605a3..ae041fbbd33a 100644
--- a/includes/HookContainer/HookRunner.php
+++ b/includes/HookContainer/HookRunner.php
@@ -104,7 +104,6 @@ class HookRunner implements
\MediaWiki\Hook\BadImageHook,
\MediaWiki\Hook\BaseTemplateAfterPortletHook,
\MediaWiki\Hook\BaseTemplateToolboxHook,
- \MediaWiki\Hook\BeforeHttpsRedirectHook,
\MediaWiki\Hook\BeforeInitializeHook,
\MediaWiki\Hook\BeforePageDisplayHook,
\MediaWiki\Hook\BeforePageRedirectHook,
@@ -119,7 +118,6 @@ class HookRunner implements
\MediaWiki\Hook\BlockIpCompleteHook,
\MediaWiki\Hook\BlockIpHook,
\MediaWiki\Hook\BookInformationHook,
- \MediaWiki\Hook\CanIPUseHTTPSHook,
\MediaWiki\Hook\CanonicalNamespacesHook,
\MediaWiki\Hook\CategoryViewer__doCategoryQueryHook,
\MediaWiki\Hook\CategoryViewer__generateLinkHook,
@@ -551,7 +549,6 @@ class HookRunner implements
\MediaWiki\User\Hook\UserLoadOptionsHook,
\MediaWiki\User\Hook\UserLogoutHook,
\MediaWiki\User\Hook\UserRemoveGroupHook,
- \MediaWiki\User\Hook\UserRequiresHTTPSHook,
\MediaWiki\User\Hook\UserResetAllOptionsHook,
\MediaWiki\User\Hook\UserRetrieveNewTalksHook,
\MediaWiki\User\Hook\UserSaveOptionsHook,
@@ -949,13 +946,6 @@ class HookRunner implements
);
}
- public function onBeforeHttpsRedirect( $context, &$redirect ) {
- return $this->container->run(
- 'BeforeHttpsRedirect',
- [ $context, &$redirect ]
- );
- }
-
public function onBeforeInitialize( $title, $unused, $output, $user, $request,
$mediaWiki
) {
@@ -1083,13 +1073,6 @@ class HookRunner implements
);
}
- public function onCanIPUseHTTPS( $ip, &$canDo ) {
- return $this->container->run(
- 'CanIPUseHTTPS',
- [ $ip, &$canDo ]
- );
- }
-
public function onCanonicalNamespaces( &$namespaces ) {
return $this->container->run(
'CanonicalNamespaces',
@@ -4333,13 +4316,6 @@ class HookRunner implements
);
}
- public function onUserRequiresHTTPS( $user, &$https ) {
- return $this->container->run(
- 'UserRequiresHTTPS',
- [ $user, &$https ]
- );
- }
-
public function onUserResetAllOptions( $user, &$newOptions, $options,
$resetKinds
) {
diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index 05f6542fb0cc..9ab3def786f3 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -1002,11 +1002,6 @@ class MediaWiki {
$oldUrl = $request->getFullRequestURL();
$redirUrl = preg_replace( '#^http://#', 'https://', $oldUrl );
- // ATTENTION: This hook is likely to be removed soon due to overall design of the system.
- if ( !$this->getHookRunner()->onBeforeHttpsRedirect( $this->context, $redirUrl ) ) {
- return false;
- }
-
if ( $request->wasPosted() ) {
// This is weird and we'd hope it almost never happens. This
// means that a POST came in via HTTP and policy requires us
diff --git a/includes/user/Hook/UserRequiresHTTPSHook.php b/includes/user/Hook/UserRequiresHTTPSHook.php
deleted file mode 100644
index 736c9aaf2b86..000000000000
--- a/includes/user/Hook/UserRequiresHTTPSHook.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-namespace MediaWiki\User\Hook;
-
-use User;
-
-/**
- * This is a hook handler interface, see docs/Hooks.md.
- * Use the hook name "UserRequiresHTTPS" to register handlers implementing this interface.
- *
- * @deprecated since 1.35
- * @ingroup Hooks
- */
-interface UserRequiresHTTPSHook {
- /**
- * This hook is called to determine whether a user needs to be switched to HTTPS.
- *
- * Deprecated since 1.35 as part of a drive towards deprecation of
- * mixed-protocol wikis.
- *
- * @since 1.35
- *
- * @param User $user User in question.
- * @param bool &$https Boolean whether $user should be switched to HTTPS.
- * @return bool|void True or no return value to continue or false to abort
- */
- public function onUserRequiresHTTPS( $user, &$https );
-}
diff --git a/includes/user/User.php b/includes/user/User.php
index 6e27f38086fc..322558d89c51 100644
--- a/includes/user/User.php
+++ b/includes/user/User.php
@@ -2871,7 +2871,6 @@ class User implements Authority, IDBAccessObject, UserIdentity, UserEmailContact
return false;
}
$https = $this->getBoolOption( 'prefershttps' );
- $this->getHookRunner()->onUserRequiresHTTPS( $this, $https );
if ( $https ) {
$https = wfCanIPUseHTTPS( $this->getRequest()->getIP() );
}
diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php
index 8cc5e5d5a4e8..ed2d7a7bfd7e 100644
--- a/tests/phpunit/includes/user/UserTest.php
+++ b/tests/phpunit/includes/user/UserTest.php
@@ -2214,7 +2214,7 @@ class UserTest extends MediaWikiIntegrationTestCase {
* @covers User::requiresHTTPS
* @dataProvider provideRequiresHTTPS
*/
- public function testRequiresHTTPS( $preference, $hook1, $hook2, bool $expected ) {
+ public function testRequiresHTTPS( $preference, bool $expected ) {
$this->setMwGlobals( [
'wgSecureLogin' => true,
'wgForceHTTPS' => false,
@@ -2224,32 +2224,14 @@ class UserTest extends MediaWikiIntegrationTestCase {
$user->setOption( 'prefershttps', $preference );
$user->saveSettings();
- $this->filterDeprecated( '/UserRequiresHTTPS hook/' );
- $this->setTemporaryHook( 'UserRequiresHTTPS', static function ( $user, &$https ) use ( $hook1 ) {
- $https = $hook1;
- return false;
- } );
- $this->filterDeprecated( '/CanIPUseHTTPS hook/' );
- $this->setTemporaryHook( 'CanIPUseHTTPS', function ( $ip, &$canDo ) use ( $hook2 ) {
- if ( $hook2 === 'notcalled' ) {
- $this->fail( 'CanIPUseHTTPS hook should not have been called' );
- }
- $canDo = $hook2;
- return false;
- } );
-
$user = User::newFromName( $user->getName() );
- $this->assertSame( $user->requiresHTTPS(), $expected );
+ $this->assertSame( $expected, $user->requiresHTTPS() );
}
public static function provideRequiresHTTPS() {
return [
- 'Wants, hook requires, can' => [ true, true, true, true ],
- 'Wants, hook requires, cannot' => [ true, true, false, false ],
- 'Wants, hook prohibits, not called' => [ true, false, 'notcalled', false ],
- 'Does not want, hook requires, can' => [ false, true, true, true ],
- 'Does not want, hook requires, cannot' => [ false, true, false, false ],
- 'Does not want, hook prohibits, not called' => [ false, false, 'notcalled', false ],
+ 'Wants, requires' => [ true, true ],
+ 'Does not want, not required' => [ false, false ],
];
}