Hoo man has uploaded a new change for review. https://gerrit.wikimedia.org/r/181423
Change subject: Improve/ sanitize protected_titles handling ...................................................................... Improve/ sanitize protected_titles handling Moved the b/c handling only relevant to MovePage into MovePage, thus unbreaking Title::getTitleProtection, which in turn fixes the protection form. Also no longer assume we can get more than one row in Title::getTitleProtection (but we only used the first row here anyway). On top of that I removed the old handling for csv `pt_create_perm` fields, as that's not being used anywhere... I checked all Wikimedia wikis by running: SELECT COUNT(*) FROM protected_titles WHERE pt_create_perm LIKE "%,%"; Bug: T85108 Change-Id: If3ee0e637ee3a3b2e260710abf79bcd5a45a74ac --- M includes/MovePage.php M includes/Title.php 2 files changed, 12 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/23/181423/1 diff --git a/includes/MovePage.php b/includes/MovePage.php index 065e189..11cc1ca 100644 --- a/includes/MovePage.php +++ b/includes/MovePage.php @@ -75,6 +75,13 @@ } else { $tp = $this->newTitle->getTitleProtection(); if ( $tp !== false ) { + if ( $tp['permission'] === 'sysop' ) { + $tp['permission'] = 'editprotected'; // B/C + } + if ( $tp['permission'] === 'autoconfirmed' ) { + $tp['permission'] = 'editsemiprotected'; // B/C + } + if ( !$user->isAllowed( $tp['permission'] ) ) { $status->fatal( 'cantmove-titleprotected' ); } diff --git a/includes/Title.php b/includes/Title.php index 4b60bcb..33d1d38 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2550,7 +2550,7 @@ if ( $this->mTitleProtection === null ) { $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( + $row = $dbr->selectRow( 'protected_titles', array( 'user' => 'pt_user', @@ -2562,17 +2562,7 @@ __METHOD__ ); - // 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 - } - } - $this->mTitleProtection = $row; + $this->mTitleProtection = (array)$row; } return $this->mTitleProtection; } @@ -3000,7 +2990,9 @@ if ( !$expiry || $expiry > $now ) { // Apply the restrictions $this->mRestrictionsExpiry['create'] = $expiry; - $this->mRestrictions['create'] = explode( ',', trim( $title_protection['permission'] ) ); + + // BC: This always used to be an array, although it never had more than one entry + $this->mRestrictions['create'] = array( $title_protection['permission'] ); } else { // Get rid of the old restrictions Title::purgeExpiredRestrictions(); $this->mTitleProtection = false; -- To view, visit https://gerrit.wikimedia.org/r/181423 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If3ee0e637ee3a3b2e260710abf79bcd5a45a74ac Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Hoo man <h...@online.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits