* show "inactive" CSS or JS.
*
* @return bool
- * @todo FIXME: Rename to isSiteConfigPage() and remove deprecated hook
+ * @since 1.31
+ */
+ public function isSiteConfigPage() {
+ return (
+ NS_MEDIAWIKI == $this->mNamespace
+ && (
+ $this->hasContentModel( CONTENT_MODEL_CSS )
+ || $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT )
+ )
+ );
+ }
+
+ /**
+ * @return bool
+ * @deprecated Since 1.31; use ::isSiteConfigPage() instead
*/
public function isCssOrJsPage() {
- $isCssOrJsPage = NS_MEDIAWIKI == $this->mNamespace
- && ( $this->hasContentModel( CONTENT_MODEL_CSS )
- || $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT ) );
+ wfDeprecated( __METHOD__, '1.31' );
+ return ( NS_MEDIAWIKI == $this->mNamespace
+ && ( $this->hasContentModel( CONTENT_MODEL_CSS )
+ || $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT ) ) );
+ }
- return $isCssOrJsPage;
+ /**
+ * Is this a "config" (.css or .js) sub-page of a user page?
+ *
+ * @return bool
+ * @since 1.31
+ */
+ public function isUserConfigPage() {
+ return (
+ NS_USER == $this->mNamespace
+ && $this->isSubpage()
+ && (
+ $this->hasContentModel( CONTENT_MODEL_CSS )
+ || $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT )
+ )
+ );
}
/**
- * Is this a .css or .js subpage of a user page?
* @return bool
- * @todo FIXME: Rename to isUserConfigPage()
+ * @deprecated Since 1.31; use ::isUserConfigPage() instead
*/
public function isCssJsSubpage() {
+ wfDeprecated( __METHOD__, '1.31' );
return ( NS_USER == $this->mNamespace && $this->isSubpage()
&& ( $this->hasContentModel( CONTENT_MODEL_CSS )
|| $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT ) ) );
* Trim down a .css or .js subpage title to get the corresponding skin name
*
* @return string Containing skin name from .css or .js subpage title
+ * @since 1.31
*/
- public function getSkinFromCssJsSubpage() {
+ public function getSkinFromConfigSubpage() {
$subpage = explode( '/', $this->mTextform );
$subpage = $subpage[count( $subpage ) - 1];
$lastdot = strrpos( $subpage, '.' );
}
/**
- * Is this a .css subpage of a user page?
+ * @deprecated Since 1.31; use ::getSkinFromConfigSubpage() instead
+ * @return string Containing skin name from .css or .js subpage title
+ */
+ public function getSkinFromCssJsSubpage() {
+ wfDeprecated( __METHOD__, '1.31' );
+ return $this->getSkinFromConfigSubpage();
+ }
+
+ /**
+ * Is this a CSS "config" sub-page of a user page?
*
* @return bool
+ * @since 1.31
+ */
+ public function isUserCssConfigPage() {
+ return (
+ NS_USER == $this->mNamespace
+ && $this->isSubpage()
+ && $this->hasContentModel( CONTENT_MODEL_CSS )
+ );
+ }
+
+ /**
+ * @deprecated Since 1.31; use ::isUserCssConfigPage()
+ * @return bool
*/
public function isCssSubpage() {
- return ( NS_USER == $this->mNamespace && $this->isSubpage()
- && $this->hasContentModel( CONTENT_MODEL_CSS ) );
+ wfDeprecated( __METHOD__, '1.31' );
+ return $this->isUserCssConfigPage();
}
/**
* Is this a .js subpage of a user page?
*
* @return bool
+ * @since 1.31
+ */
+ public function isUserJsConfigPage() {
+ return (
+ NS_USER == $this->mNamespace
+ && $this->isSubpage()
+ && $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT )
+ );
+ }
+
+ /**
+ * @deprecated Since 1.31; use ::isUserJsConfigPage()
+ * @return bool
*/
public function isJsSubpage() {
- return ( NS_USER == $this->mNamespace && $this->isSubpage()
- && $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT ) );
+ wfDeprecated( __METHOD__, '1.31' );
+ return $this->isUserJsConfigPage();
}
/**
* @see wfExpandUrl
* @param string|string[] $query
* @param string|string[]|bool $query2
- * @param string $proto Protocol type to use in URL
+ * @param string|int|null $proto Protocol type to use in URL
* @return string The URL
*/
public function getFullURL( $query = '', $query2 = false, $proto = PROTO_RELATIVE ) {
if ( $this->isExternal() ) {
$target = SpecialPage::getTitleFor(
'GoToInterwiki',
- $this->getPrefixedDBKey()
+ $this->getPrefixedDBkey()
);
}
- return $target->getFullUrl( $query, false, $proto );
+ return $target->getFullURL( $query, false, $proto );
}
/**
*
* @return array List of errors
*/
- private function checkCSSandJSPermissions( $action, $user, $errors, $rigor, $short ) {
+ private function checkUserConfigPermissions( $action, $user, $errors, $rigor, $short ) {
# Protect css/js subpages of user pages
# XXX: this might be better using restrictions
+
if ( $action != 'patrol' ) {
if ( preg_match( '/^' . preg_quote( $user->getName(), '/' ) . '\//', $this->mTextform ) ) {
- if ( $this->isCssSubpage() && !$user->isAllowedAny( 'editmyusercss', 'editusercss' ) ) {
+ if (
+ $this->isUserCssConfigPage()
+ && !$user->isAllowedAny( 'editmyusercss', 'editusercss' )
+ ) {
$errors[] = [ 'mycustomcssprotected', $action ];
- } elseif ( $this->isJsSubpage() && !$user->isAllowedAny( 'editmyuserjs', 'edituserjs' ) ) {
+ } elseif (
+ $this->isUserJsConfigPage()
+ && !$user->isAllowedAny( 'editmyuserjs', 'edituserjs' )
+ ) {
$errors[] = [ 'mycustomjsprotected', $action ];
}
} else {
- if ( $this->isCssSubpage() && !$user->isAllowed( 'editusercss' ) ) {
+ if (
+ $this->isUserCssConfigPage()
+ && !$user->isAllowed( 'editusercss' )
+ ) {
$errors[] = [ 'customcssprotected', $action ];
- } elseif ( $this->isJsSubpage() && !$user->isAllowed( 'edituserjs' ) ) {
+ } elseif (
+ $this->isUserJsConfigPage()
+ && !$user->isAllowed( 'edituserjs' )
+ ) {
$errors[] = [ 'customjsprotected', $action ];
}
}
* @return array List of errors
*/
private function checkCascadingSourcesRestrictions( $action, $user, $errors, $rigor, $short ) {
- if ( $rigor !== 'quick' && !$this->isCssJsSubpage() ) {
+ if ( $rigor !== 'quick' && !$this->isUserConfigPage() ) {
# We /could/ use the protection level on the source page, but it's
# fairly ugly as we have to establish a precedence hierarchy for pages
# included by multiple cascade-protected pages. So just restrict
'checkReadPermissions',
'checkUserBlock', // for wgBlockDisablesLogin
];
- # Don't call checkSpecialsAndNSPermissions or checkCSSandJSPermissions
+ # Don't call checkSpecialsAndNSPermissions or checkUserConfigPermissions
# here as it will lead to duplicate error messages. This is okay to do
# since anywhere that checks for create will also check for edit, and
# those checks are called for edit.
'checkQuickPermissions',
'checkPermissionHooks',
'checkSpecialsAndNSPermissions',
- 'checkCSSandJSPermissions',
+ 'checkUserConfigPermissions',
'checkPageRestrictions',
'checkCascadingSourcesRestrictions',
'checkActionPermissions',
if ( $this->mTitleProtection === null ) {
$dbr = wfGetDB( DB_REPLICA );
- $commentStore = new CommentStore( 'pt_reason' );
- $commentQuery = $commentStore->getJoin();
+ $commentStore = CommentStore::getStore();
+ $commentQuery = $commentStore->getJoin( 'pt_reason' );
$res = $dbr->select(
[ 'protected_titles' ] + $commentQuery['tables'],
[
'user' => $row['user'],
'expiry' => $dbr->decodeExpiry( $row['expiry'] ),
'permission' => $row['permission'],
- 'reason' => $commentStore->getComment( $row )->text,
+ 'reason' => $commentStore->getComment( 'pt_reason', $row )->text,
];
} else {
$this->mTitleProtection = false;
}
// If we are looking at a css/js user subpage, purge the action=raw.
- if ( $this->isJsSubpage() ) {
+ if ( $this->isUserJsConfigPage() ) {
$urls[] = $this->getInternalURL( 'action=raw&ctype=text/javascript' );
- } elseif ( $this->isCssSubpage() ) {
+ } elseif ( $this->isUserCssConfigPage() ) {
$urls[] = $this->getInternalURL( 'action=raw&ctype=text/css' );
}
return $authors;
}
$dbr = wfGetDB( DB_REPLICA );
- $res = $dbr->select( 'revision', 'DISTINCT rev_user_text',
+ $revQuery = Revision::getQueryInfo();
+ $authors = $dbr->selectFieldValues(
+ $revQuery['tables'],
+ $revQuery['fields']['rev_user_text'],
[
'rev_page' => $this->getArticleID(),
"rev_timestamp $old_cmp " . $dbr->addQuotes( $dbr->timestamp( $old->getTimestamp() ) ),
"rev_timestamp $new_cmp " . $dbr->addQuotes( $dbr->timestamp( $new->getTimestamp() ) )
], __METHOD__,
- [ 'LIMIT' => $limit + 1 ] // add one so caller knows it was truncated
+ [ 'DISTINCT', 'LIMIT' => $limit + 1 ], // add one so caller knows it was truncated
+ $revQuery['joins']
);
- foreach ( $res as $row ) {
- $authors[] = $row->rev_user_text;
- }
return $authors;
}
}
if ( $this->isExternal() ) {
- return true; // any interwiki link might be viewable, for all we know
+ return true; // any interwiki link might be viewable, for all we know
}
switch ( $this->mNamespace ) {