X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2FTitle.php;h=a5bb9c691fddb3575fc0f14c221c399d93e94b85;hb=251b25d700dcaa7bca93864cb61ca4d719cfc6dd;hp=b810b36e9319cac7da4d822b20789ab489ef60a0;hpb=1d7141b4de1c25ac07a257255e7707a6fa666c34;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Title.php b/includes/Title.php index b810b36e93..a5bb9c691f 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2549,6 +2549,29 @@ class Title implements LinkTarget { * 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 @@ class Title implements LinkTarget { // 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; @@ -2926,8 +2943,6 @@ class Title implements LinkTarget { continue; } - // This code should be refactored, now that it's being used more generally, - // But I don't really see any harm in leaving it in Block for now -werdna $expiry = $dbr->decodeExpiry( $row->pr_expiry ); // Only apply the restrictions if they haven't expired! @@ -2979,7 +2994,7 @@ class Title implements LinkTarget { $this->loadRestrictionsFromRows( $rows, $oldFashionedRestrictions ); } else { - $title_protection = $this->getTitleProtection(); + $title_protection = $this->getTitleProtectionInternal(); if ( $title_protection ) { $now = wfTimestampNow(); @@ -3865,7 +3880,7 @@ class Title implements LinkTarget { * categories' names. * * @return array Array of parents in the form: - * $parent => $currentarticle + * $parent => $currentarticle */ public function getParentCategories() { global $wgContLang;