/**
* @var int Namespace index when there is no namespace. Don't change the
- * following default, NS_MAIN is hardcoded in several places. See bug 696.
+ * following default, NS_MAIN is hardcoded in several places. See T2696.
* Zero except in {{transclusion}} tags.
*/
public $mDefaultNamespace = NS_MAIN;
}
}
- // Convert things like é ā or 〗 into normalized (bug 14952) text
+ // Convert things like é ā or 〗 into normalized (T16952) text
$filteredText = Sanitizer::decodeCharReferencesAndNormalize( $text );
$t = new Title();
&& ( $this->hasContentModel( CONTENT_MODEL_CSS )
|| $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT ) );
- # @note This hook is also called in ContentHandler::getDefaultModel.
- # It's called here again to make sure hook functions can force this
- # method to return true even outside the MediaWiki namespace.
-
- Hooks::run( 'TitleIsCssOrJsPage', [ $this, &$isCssOrJsPage ], '1.25' );
-
return $isCssOrJsPage;
}
# Finally, add the fragment.
$url .= $this->getFragmentForURL();
-
- Hooks::run( 'GetFullURL', [ &$this, &$url, $query ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $titleRef = $this;
+ Hooks::run( 'GetFullURL', [ &$titleRef, &$url, $query ] );
return $url;
}
$dbkey = wfUrlencode( $this->getPrefixedDBkey() );
if ( $query == '' ) {
$url = str_replace( '$1', $dbkey, $wgArticlePath );
- Hooks::run( 'GetLocalURL::Article', [ &$this, &$url ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $titleRef = $this;
+ Hooks::run( 'GetLocalURL::Article', [ &$titleRef, &$url ] );
} else {
global $wgVariantArticlePath, $wgActionPaths, $wgContLang;
$url = false;
$url = "{$wgScript}?title={$dbkey}&{$query}";
}
}
-
- Hooks::run( 'GetLocalURL::Internal', [ &$this, &$url, $query ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $titleRef = $this;
+ Hooks::run( 'GetLocalURL::Internal', [ &$titleRef, &$url, $query ] );
// @todo FIXME: This causes breakage in various places when we
// actually expected a local URL and end up with dupe prefixes.
$url = $wgServer . $url;
}
}
- Hooks::run( 'GetLocalURL', [ &$this, &$url, $query ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $titleRef = $this;
+ Hooks::run( 'GetLocalURL', [ &$titleRef, &$url, $query ] );
return $url;
}
$query = self::fixUrlQueryArgs( $query, $query2 );
$server = $wgInternalServer !== false ? $wgInternalServer : $wgServer;
$url = wfExpandUrl( $server . $this->getLocalURL( $query ), PROTO_HTTP );
- Hooks::run( 'GetInternalURL', [ &$this, &$url, $query ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $titleRef = $this;
+ Hooks::run( 'GetInternalURL', [ &$titleRef, &$url, $query ] );
return $url;
}
public function getCanonicalURL( $query = '', $query2 = false ) {
$query = self::fixUrlQueryArgs( $query, $query2 );
$url = wfExpandUrl( $this->getLocalURL( $query ) . $this->getFragmentForURL(), PROTO_CANONICAL );
- Hooks::run( 'GetCanonicalURL', [ &$this, &$url, $query ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $titleRef = $this;
+ Hooks::run( 'GetCanonicalURL', [ &$titleRef, &$url, $query ] );
return $url;
}
private function checkPermissionHooks( $action, $user, $errors, $rigor, $short ) {
// Use getUserPermissionsErrors instead
$result = '';
- if ( !Hooks::run( 'userCan', [ &$this, &$user, $action, &$result ] ) ) {
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $titleRef = $this;
+ if ( !Hooks::run( 'userCan', [ &$titleRef, &$user, $action, &$result ] ) ) {
return $result ? [] : [ [ 'badaccess-group0' ] ];
}
// Check getUserPermissionsErrors hook
- if ( !Hooks::run( 'getUserPermissionsErrors', [ &$this, &$user, $action, &$result ] ) ) {
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $titleRef = $this;
+ if ( !Hooks::run( 'getUserPermissionsErrors', [ &$titleRef, &$user, $action, &$result ] ) ) {
$errors = $this->resultToError( $errors, $result );
}
// Check getUserPermissionsErrorsExpensive hook
if (
$rigor !== 'quick'
&& !( $short && count( $errors ) > 0 )
- && !Hooks::run( 'getUserPermissionsErrorsExpensive', [ &$this, &$user, $action, &$result ] )
+ && !Hooks::run( 'getUserPermissionsErrorsExpensive', [ &$titleRef, &$user, $action, &$result ] )
) {
$errors = $this->resultToError( $errors, $result );
}
*
* @param string $action The action to check
* @param bool $short Short circuit on first error
- * @return array List of errors
+ * @return array Array containing an error message key and any parameters
*/
private function missingPermissionError( $action, $short ) {
// We avoid expensive display logic for quickUserCan's and such
return [ 'badaccess-group0' ];
}
- $groups = array_map( [ 'User', 'makeGroupLinkWiki' ],
- User::getGroupsWithPermission( $action ) );
-
- if ( count( $groups ) ) {
- global $wgLang;
- return [
- 'badaccess-groups',
- $wgLang->commaList( $groups ),
- count( $groups )
- ];
- } else {
- return [ 'badaccess-group0' ];
- }
+ return User::newFatalPermissionDeniedStatus( $action )->getErrorsArray()[0];
}
/**
* 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;
// 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;
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!
$this->loadRestrictionsFromRows( $rows, $oldFashionedRestrictions );
} else {
- $title_protection = $this->getTitleProtection();
+ $title_protection = $this->getTitleProtectionInternal();
if ( $title_protection ) {
$now = wfTimestampNow();
);
}
- /**
- * Move this page without authentication
- *
- * @deprecated since 1.25 use MovePage class instead
- * @param Title $nt The new page Title
- * @return array|bool True on success, getUserPermissionsErrors()-like array on failure
- */
- public function moveNoAuth( &$nt ) {
- wfDeprecated( __METHOD__, '1.25' );
- return $this->moveTo( $nt, false );
- }
-
/**
* Check whether a given move operation would be valid.
* Returns true if ok, or a getUserPermissionsErrors()-like array otherwise
}
$newPageName = preg_replace(
'#^' . preg_quote( $this->getDBkey(), '#' ) . '#',
- StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # bug 21234
+ StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # T23234
$oldSubpage->getDBkey() );
if ( $oldSubpage->isTalkPage() ) {
$newNs = $nt->getTalkPage()->getNamespace();
} else {
$newNs = $nt->getSubjectPage()->getNamespace();
}
- # Bug 14385: we need makeTitleSafe because the new page names may
+ # T16385: we need makeTitleSafe because the new page names may
# be longer than 255 characters.
$newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
* categories' names.
*
* @return array Array of parents in the form:
- * $parent => $currentarticle
+ * $parent => $currentarticle
*/
public function getParentCategories() {
global $wgContLang;