Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/185095
Change subject: Made EditPage avoid querying the master block table on form view
......................................................................
Made EditPage avoid querying the master block table on form view
bug: T51419
Change-Id: Ic1882aa2957eed2b978761b5fc34ea9bdd8981b5
---
M includes/EditPage.php
M includes/Title.php
2 files changed, 18 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/95/185095/1
diff --git a/includes/EditPage.php b/includes/EditPage.php
index cb79fd1..96ecb4d 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -504,7 +504,7 @@
}
}
- $permErrors = $this->getEditPermissionErrors();
+ $permErrors = $this->getEditPermissionErrors( $this->save );
if ( $permErrors ) {
wfDebug( __METHOD__ . ": User can't edit\n" );
// Auto-block user's IP if the account was "hard"
blocked
@@ -559,15 +559,22 @@
}
/**
+ * @param bool $doExpensive Do "expensive" permission checks
* @return array
*/
- protected function getEditPermissionErrors() {
+ protected function getEditPermissionErrors( $doExpensive = true ) {
global $wgUser;
- $permErrors = $this->mTitle->getUserPermissionsErrors( 'edit',
$wgUser );
+
+ $permErrors = $this->mTitle->getUserPermissionsErrors( 'edit',
$wgUser, $doExpensive );
# Can this title be created?
if ( !$this->mTitle->exists() ) {
- $permErrors = array_merge( $permErrors,
- wfArrayDiff2(
$this->mTitle->getUserPermissionsErrors( 'create', $wgUser ), $permErrors ) );
+ $permErrors = array_merge(
+ $permErrors,
+ wfArrayDiff2(
+
$this->mTitle->getUserPermissionsErrors( 'create', $wgUser, $doExpensive ),
+ $permErrors
+ )
+ );
}
# Ignore some permissions errors when a user is just
previewing/viewing diffs
$remove = array();
@@ -579,6 +586,7 @@
}
}
$permErrors = wfArrayDiff2( $permErrors, $remove );
+
return $permErrors;
}
diff --git a/includes/Title.php b/includes/Title.php
index bb4d04e..7422dbc 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -2310,10 +2310,13 @@
$errors[] = array( 'confirmedittext' );
}
- if ( ( $action == 'edit' || $action == 'create' ) &&
!$user->isBlockedFrom( $this ) ) {
+ $useSlave = !$doExpensiveQueries;
+ if ( ( $action == 'edit' || $action == 'create' )
+ && !$user->isBlockedFrom( $this, $useSlave )
+ ) {
// Don't block the user from editing their own talk
page unless they've been
// explicitly blocked from that too.
- } elseif ( $user->isBlocked() && $user->mBlock->prevents(
$action ) !== false ) {
+ } elseif ( $user->isBlocked() && $user->getBlock()->prevents(
$action ) !== false ) {
// @todo FIXME: Pass the relevant context into this
function.
$errors[] = $user->getBlock()->getPermissionsError(
RequestContext::getMain() );
}
--
To view, visit https://gerrit.wikimedia.org/r/185095
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic1882aa2957eed2b978761b5fc34ea9bdd8981b5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits