aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api')
-rw-r--r--includes/api/ApiMain.php1
-rw-r--r--includes/api/ApiProtect.php11
-rw-r--r--includes/api/ApiQuery.php1
-rw-r--r--includes/api/ApiQueryInfo.php10
4 files changed, 19 insertions, 4 deletions
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index f7cb278c3afe..543b2c97b2b0 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -276,6 +276,7 @@ class ApiMain extends ApiBase {
'services' => [
'WatchlistManager',
'UserOptionsLookup',
+ 'RestrictionStore',
]
],
'block' => [
diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php
index 5d02fb812c1d..bc9ea1c6dc01 100644
--- a/includes/api/ApiProtect.php
+++ b/includes/api/ApiProtect.php
@@ -21,6 +21,7 @@
*/
use MediaWiki\MainConfigNames;
+use MediaWiki\Permissions\RestrictionStore;
use MediaWiki\User\UserOptionsLookup;
use MediaWiki\Watchlist\WatchlistManager;
@@ -31,19 +32,25 @@ class ApiProtect extends ApiBase {
use ApiWatchlistTrait;
+ /** @var RestrictionStore */
+ private $restrictionStore;
+
/**
* @param ApiMain $mainModule
* @param string $moduleName
* @param WatchlistManager $watchlistManager
* @param UserOptionsLookup $userOptionsLookup
+ * @param RestrictionStore $restrictionStore
*/
public function __construct(
ApiMain $mainModule,
$moduleName,
WatchlistManager $watchlistManager,
- UserOptionsLookup $userOptionsLookup
+ UserOptionsLookup $userOptionsLookup,
+ RestrictionStore $restrictionStore
) {
parent::__construct( $mainModule, $moduleName );
+ $this->restrictionStore = $restrictionStore;
// Variables needed in ApiWatchlistTrait trait
$this->watchlistExpiryEnabled = $this->getConfig()->get( MainConfigNames::WatchlistExpiry );
@@ -86,7 +93,7 @@ class ApiProtect extends ApiBase {
}
}
- $restrictionTypes = $titleObj->getRestrictionTypes();
+ $restrictionTypes = $this->restrictionStore->listApplicableRestrictionTypes( $titleObj );
$levels = $this->getPermissionManager()->getNamespaceRestrictionLevels(
$titleObj->getNamespace(),
$user
diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php
index 09e88e269cac..fd1dd25d7ccd 100644
--- a/includes/api/ApiQuery.php
+++ b/includes/api/ApiQuery.php
@@ -105,6 +105,7 @@ class ApiQuery extends ApiBase {
'TitleFormatter',
'WatchedItemStore',
'LanguageConverterFactory',
+ 'RestrictionStore',
],
],
'links' => [
diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php
index d9aac4335ec1..ac6b9e74550c 100644
--- a/includes/api/ApiQueryInfo.php
+++ b/includes/api/ApiQueryInfo.php
@@ -26,6 +26,7 @@ use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\ParamValidator\TypeDef\TitleDef;
use MediaWiki\Permissions\PermissionStatus;
+use MediaWiki\Permissions\RestrictionStore;
/**
* A query module to show basic page information.
@@ -46,6 +47,8 @@ class ApiQueryInfo extends ApiQueryBase {
private $titleFormatter;
/** @var WatchedItemStore */
private $watchedItemStore;
+ /** @var RestrictionStore */
+ private $restrictionStore;
private $fld_protection = false, $fld_talkid = false,
$fld_subjectid = false, $fld_url = false,
@@ -106,6 +109,7 @@ class ApiQueryInfo extends ApiQueryBase {
* @param TitleFormatter $titleFormatter
* @param WatchedItemStore $watchedItemStore
* @param LanguageConverterFactory $languageConverterFactory
+ * @param RestrictionStore $restrictionStore
*/
public function __construct(
ApiQuery $queryModule,
@@ -116,7 +120,8 @@ class ApiQueryInfo extends ApiQueryBase {
TitleFactory $titleFactory,
TitleFormatter $titleFormatter,
WatchedItemStore $watchedItemStore,
- LanguageConverterFactory $languageConverterFactory
+ LanguageConverterFactory $languageConverterFactory,
+ RestrictionStore $restrictionStore
) {
parent::__construct( $queryModule, $moduleName, 'in' );
$this->languageConverter = $languageConverterFactory->getLanguageConverter( $contentLanguage );
@@ -125,6 +130,7 @@ class ApiQueryInfo extends ApiQueryBase {
$this->titleFactory = $titleFactory;
$this->titleFormatter = $titleFormatter;
$this->watchedItemStore = $watchedItemStore;
+ $this->restrictionStore = $restrictionStore;
}
/**
@@ -519,7 +525,7 @@ class ApiQueryInfo extends ApiQueryBase {
}
// Applicable protection types
$this->restrictionTypes[$title->getNamespace()][$title->getDBkey()] =
- array_values( $title->getRestrictionTypes() );
+ array_values( $this->restrictionStore->listApplicableRestrictionTypes( $title ) );
}
$linksMigration = MediaWikiServices::getInstance()->getLinksMigration();