jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/335996 )
Change subject: Fix Title::loadRestrictions() for create-protected titles
......................................................................
Fix Title::loadRestrictions() for create-protected titles
Title::loadRestrictions() returns restriction levels, not the
corresponding user rights. These are mostly identical except for the
backwards-compatibility levels "sysop" and "autoconfirmed".
For create protection it calls Title::getTitleProtection() to fetch
them, but Ic5026384 changed that to return rights. Split that function
into two, an internal method that returns restriction levels for
loadRestrictions() to call and the public method that converts levels
into rights.
Bug: T85108
Change-Id: I3ea4cb9c5e37b746402744dd7a883763ee07195a
---
M includes/Title.php
1 file changed, 24 insertions(+), 7 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Title.php b/includes/Title.php
index 13a6f56..3ed6b8b 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -2549,6 +2549,29 @@
* protection, or false if there's none.
*/
public function getTitleProtection() {
+ $protection = $this->getTitleProtectionInternal();
+ if ( $protection ) {
+ if ( $protection['permission'] == 'sysop' ) {
+ $protection['permission'] = 'editprotected'; //
B/C
+ }
+ if ( $protection['permission'] == 'autoconfirmed' ) {
+ $protection['permission'] =
'editsemiprotected'; // B/C
+ }
+ }
+ return $protection;
+ }
+
+ /**
+ * Fetch title protection settings
+ *
+ * To work correctly, $this->loadRestrictions() needs to have access to
the
+ * actual protections in the database without munging 'sysop' =>
+ * 'editprotected' and 'autoconfirmed' => 'editsemiprotected'. Other
+ * callers probably want $this->getTitleProtection() instead.
+ *
+ * @return array|bool
+ */
+ protected function getTitleProtectionInternal() {
// Can't protect pages in special namespaces
if ( $this->getNamespace() < 0 ) {
return false;
@@ -2576,12 +2599,6 @@
// fetchRow returns false if there are no rows.
$row = $dbr->fetchRow( $res );
if ( $row ) {
- if ( $row['permission'] == 'sysop' ) {
- $row['permission'] = 'editprotected';
// B/C
- }
- if ( $row['permission'] == 'autoconfirmed' ) {
- $row['permission'] =
'editsemiprotected'; // B/C
- }
$row['expiry'] = $dbr->decodeExpiry(
$row['expiry'] );
}
$this->mTitleProtection = $row;
@@ -2979,7 +2996,7 @@
$this->loadRestrictionsFromRows( $rows,
$oldFashionedRestrictions );
} else {
- $title_protection = $this->getTitleProtection();
+ $title_protection = $this->getTitleProtectionInternal();
if ( $title_protection ) {
$now = wfTimestampNow();
--
To view, visit https://gerrit.wikimedia.org/r/335996
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3ea4cb9c5e37b746402744dd7a883763ee07195a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits