PleaseStand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/65785
Change subject: Check if API enabled before loading dependent JS modules
......................................................................
Check if API enabled before loading dependent JS modules
Affects whether these modules are loaded:
* mediawiki.searchSuggest ($wgEnableAPI only)
* mediawiki.page.watch.ajax ($wgEnableAPI, $wgEnableWriteAPI,
'writeapi' right)
* mediawiki.page.patrol.ajax (same as above)
Checking of $wgUseAjax has not been removed where it was
already present, in case some users have set the variable
to false to disable these specific features.
Bug: 30213
Change-Id: If2ec219cfbb94e7c9718c58b9b54a508d0e0c656
---
M RELEASE-NOTES-1.22
M includes/Article.php
M includes/OutputPage.php
M includes/diff/DifferenceEngine.php
4 files changed, 24 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/85/65785/1
diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 4e04940..f3905e4 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -112,6 +112,9 @@
* (bug 36641) Patrol page links no longer show on non-existent revisions.
* (bug 35810) Pages not linked from Special:RecentChanges or Special:NewPages
are patrollable now.
+* (bug 30213) JavaScript for search suggestions is now disabled when the API
+ is disabled, and AJAX patrolling and watching are now disabled when use of
+ the write API is not allowed.
=== API changes in 1.22 ===
* (bug 46626) xmldoublequote parameter was removed. Because of a bug, the
diff --git a/includes/Article.php b/includes/Article.php
index c4b0835..da24a98 100644
--- a/includes/Article.php
+++ b/includes/Article.php
@@ -1052,7 +1052,7 @@
* OutputPage::preventClickjacking() and load
mediawiki.page.patrol.ajax.
*/
public function showPatrolFooter() {
- global $wgUseRCPatrol, $wgUseNPPatrol, $wgRCMaxAge;
+ global $wgUseRCPatrol, $wgUseNPPatrol, $wgRCMaxAge,
$wgEnableAPI, $wgEnableWriteAPI;
$request = $this->getContext()->getRequest();
$outputPage = $this->getContext()->getOutput();
@@ -1167,7 +1167,9 @@
$token = $user->getEditToken( $rcid );
$outputPage->preventClickjacking();
- $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
+ if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed(
'writeapi' ) ) {
+ $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
+ }
$link = Linker::linkKnown(
$this->getTitle(),
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index b63e658..39802ed 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -2558,7 +2558,7 @@
*/
private function addDefaultModules() {
global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil,
$wgUseAjax,
- $wgAjaxWatch, $wgResponsiveImages;
+ $wgAjaxWatch, $wgResponsiveImages, $wgEnableAPI,
$wgEnableWriteAPI;
// Add base resources
$this->addModules( array(
@@ -2582,12 +2582,17 @@
wfRunHooks( 'AjaxAddScript', array( &$this ) );
- if ( $wgAjaxWatch && $this->getUser()->isLoggedIn() ) {
- $this->addModules( 'mediawiki.page.watch.ajax'
);
- }
+ if ( $wgEnableAPI ) {
+ $user = $this->getUser();
+ if ( $wgEnableWriteAPI && $wgAjaxWatch &&
$user->isLoggedIn()
+ && $user->isAllowed( 'writeapi' )
+ ) {
+ $this->addModules(
'mediawiki.page.watch.ajax' );
+ }
- if ( !$this->getUser()->getOption( 'disablesuggest',
false ) ) {
- $this->addModules( 'mediawiki.searchSuggest' );
+ if ( !$this->getUser()->getOption(
'disablesuggest', false ) ) {
+ $this->addModules(
'mediawiki.searchSuggest' );
+ }
}
}
diff --git a/includes/diff/DifferenceEngine.php
b/includes/diff/DifferenceEngine.php
index c551107..5cdc0b6 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -410,7 +410,7 @@
* @return String
*/
protected function markPatrolledLink() {
- global $wgUseRCPatrol, $wgRCMaxAge;
+ global $wgUseRCPatrol, $wgRCMaxAge, $wgEnableAPI,
$wgEnableWriteAPI;
$cache = wfGetMainCache();
if ( $this->mMarkPatrolledLink === null ) {
@@ -447,7 +447,11 @@
// Build the link
if ( $rcid ) {
$this->getOutput()->preventClickjacking();
- $this->getOutput()->addModules(
'mediawiki.page.patrol.ajax' );
+ if ( $wgEnableAPI && $wgEnableWriteAPI
+ && $this->getUser()->isAllowed(
'writeapi' )
+ ) {
+ $this->getOutput()->addModules(
'mediawiki.page.patrol.ajax' );
+ }
$token =
$this->getUser()->getEditToken( $rcid );
$this->mMarkPatrolledLink = ' <span
class="patrollink">[' . Linker::linkKnown(
--
To view, visit https://gerrit.wikimedia.org/r/65785
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If2ec219cfbb94e7c9718c58b9b54a508d0e0c656
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits