summaryrefslogtreecommitdiff
path: root/includes/specialpage
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:32:59 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:32:59 -0400
commit6dc1997577fab2c366781fd7048144935afa0012 (patch)
tree8918d28c7ab4342f0738985e37af1dfc42d0e93a /includes/specialpage
parent150f94f051128f367bc89f6b7e5f57eb2a69fc62 (diff)
parentfa89acd685cb09cdbe1c64cbb721ec64975bbbc1 (diff)
Merge commit 'fa89acd'
# Conflicts: # .gitignore # extensions/ArchInterWiki.sql
Diffstat (limited to 'includes/specialpage')
-rw-r--r--includes/specialpage/ChangesListSpecialPage.php3
-rw-r--r--includes/specialpage/FormSpecialPage.php6
-rw-r--r--includes/specialpage/QueryPage.php49
-rw-r--r--includes/specialpage/RedirectSpecialPage.php45
-rw-r--r--includes/specialpage/SpecialPage.php27
-rw-r--r--includes/specialpage/SpecialPageFactory.php61
6 files changed, 103 insertions, 88 deletions
diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php
index b9132358..23bd394c 100644
--- a/includes/specialpage/ChangesListSpecialPage.php
+++ b/includes/specialpage/ChangesListSpecialPage.php
@@ -434,7 +434,8 @@ abstract class ChangesListSpecialPage extends SpecialPage {
$legend .= Html::element( 'dt',
array( 'class' => $cssClass ), $context->msg( $letter )->text()
) . "\n" .
- Html::rawElement( 'dd', array(),
+ Html::rawElement( 'dd',
+ array( 'class' => Sanitizer::escapeClass( 'mw-changeslist-legend-' . $key ) ),
$context->msg( $label )->parse()
) . "\n";
}
diff --git a/includes/specialpage/FormSpecialPage.php b/includes/specialpage/FormSpecialPage.php
index 90567617..42c59806 100644
--- a/includes/specialpage/FormSpecialPage.php
+++ b/includes/specialpage/FormSpecialPage.php
@@ -96,7 +96,11 @@ abstract class FormSpecialPage extends SpecialPage {
$this->getMessagePrefix()
);
$form->setSubmitCallback( array( $this, 'onSubmit' ) );
- $form->setWrapperLegendMsg( $this->getMessagePrefix() . '-legend' );
+ if ( $this->getDisplayFormat() !== 'ooui' ) {
+ // No legend and wrapper by default in OOUI forms, but can be set manually
+ // from alterForm()
+ $form->setWrapperLegendMsg( $this->getMessagePrefix() . '-legend' );
+ }
$headerMsg = $this->msg( $this->getMessagePrefix() . '-text' );
if ( !$headerMsg->isDisabled() ) {
diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php
index 1ff7e3fb..3c8b7420 100644
--- a/includes/specialpage/QueryPage.php
+++ b/includes/specialpage/QueryPage.php
@@ -70,7 +70,7 @@ abstract class QueryPage extends SpecialPage {
array( 'DeadendPagesPage', 'Deadendpages' ),
array( 'DoubleRedirectsPage', 'DoubleRedirects' ),
array( 'FileDuplicateSearchPage', 'FileDuplicateSearch' ),
- array( 'ListDuplicatedFilesPage', 'ListDuplicatedFiles'),
+ array( 'ListDuplicatedFilesPage', 'ListDuplicatedFiles' ),
array( 'LinkSearchPage', 'LinkSearch' ),
array( 'ListredirectsPage', 'Listredirects' ),
array( 'LonelyPagesPage', 'Lonelypages' ),
@@ -141,7 +141,7 @@ abstract class QueryPage extends SpecialPage {
* @return array
* @since 1.18
*/
- function getQueryInfo() {
+ public function getQueryInfo() {
return null;
}
@@ -178,7 +178,7 @@ abstract class QueryPage extends SpecialPage {
* @return bool
* @since 1.18
*/
- function usesTimestamps() {
+ public function usesTimestamps() {
return false;
}
@@ -198,7 +198,7 @@ abstract class QueryPage extends SpecialPage {
*
* @return bool
*/
- function isExpensive() {
+ public function isExpensive() {
return $this->getConfig()->get( 'DisableQueryPages' );
}
@@ -219,7 +219,7 @@ abstract class QueryPage extends SpecialPage {
*
* @return bool
*/
- function isCached() {
+ public function isCached() {
return $this->isExpensive() && $this->getConfig()->get( 'MiserMode' );
}
@@ -253,6 +253,17 @@ abstract class QueryPage extends SpecialPage {
}
/**
+ * Outputs some kind of an informative message (via OutputPage) to let the
+ * user know that the query returned nothing and thus there's nothing to
+ * show.
+ *
+ * @since 1.26
+ */
+ protected function showEmptyText() {
+ $this->getOutput()->addWikiMsg( 'specialpage-empty' );
+ }
+
+ /**
* If using extra form wheely-dealies, return a set of parameters here
* as an associative array. They will be encoded and added to the paging
* links (prev/next/lengths).
@@ -283,7 +294,7 @@ abstract class QueryPage extends SpecialPage {
* @throws DBError|Exception
* @return bool|int
*/
- function recache( $limit, $ignoreErrors = true ) {
+ public function recache( $limit, $ignoreErrors = true ) {
if ( !$this->isCacheable() ) {
return 0;
}
@@ -359,7 +370,7 @@ abstract class QueryPage extends SpecialPage {
* @return ResultWrapper
* @since 1.18
*/
- function reallyDoQuery( $limit, $offset = false ) {
+ public function reallyDoQuery( $limit, $offset = false ) {
$fname = get_class( $this ) . "::reallyDoQuery";
$dbr = $this->getRecacheDB();
$query = $this->getQueryInfo();
@@ -410,7 +421,7 @@ abstract class QueryPage extends SpecialPage {
* @param int|bool $limit
* @return ResultWrapper
*/
- function doQuery( $offset = false, $limit = false ) {
+ public function doQuery( $offset = false, $limit = false ) {
if ( $this->isCached() && $this->isCacheable() ) {
return $this->fetchFromCache( $limit, $offset );
} else {
@@ -425,7 +436,7 @@ abstract class QueryPage extends SpecialPage {
* @return ResultWrapper
* @since 1.18
*/
- function fetchFromCache( $limit, $offset = false ) {
+ public function fetchFromCache( $limit, $offset = false ) {
$dbr = wfGetDB( DB_SLAVE );
$options = array();
if ( $limit !== false ) {
@@ -460,11 +471,23 @@ abstract class QueryPage extends SpecialPage {
}
/**
+ * Returns limit and offset, as returned by $this->getRequest()->getLimitOffset().
+ * Subclasses may override this to further restrict or modify limit and offset.
+ *
+ * @since 1.26
+ *
+ * @return int[] list( $limit, $offset )
+ */
+ protected function getLimitOffset() {
+ return $this->getRequest()->getLimitOffset();
+ }
+
+ /**
* This is the actual workhorse. It does everything needed to make a
* real, honest-to-gosh query page.
* @param string $par
*/
- function execute( $par ) {
+ public function execute( $par ) {
$user = $this->getUser();
if ( !$this->userCanExecute( $user ) ) {
$this->displayRestrictionError();
@@ -484,7 +507,7 @@ abstract class QueryPage extends SpecialPage {
$out->setSyndicated( $this->isSyndicated() );
if ( $this->limit == 0 && $this->offset == 0 ) {
- list( $this->limit, $this->offset ) = $this->getRequest()->getLimitOffset();
+ list( $this->limit, $this->offset ) = $this->getLimitOffset();
}
// @todo Use doQuery()
@@ -527,7 +550,7 @@ abstract class QueryPage extends SpecialPage {
$this->numRows = $res->numRows();
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = $this->getRecacheDB();
$this->preprocessResults( $dbr, $res );
$out->addHTML( Xml::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) );
@@ -546,7 +569,7 @@ abstract class QueryPage extends SpecialPage {
} else {
# No results to show, so don't bother with "showing X of Y" etc.
# -- just let the user know and give up now
- $out->addWikiMsg( 'specialpage-empty' );
+ $this->showEmptyText();
$out->addHTML( Xml::closeElement( 'div' ) );
return;
}
diff --git a/includes/specialpage/RedirectSpecialPage.php b/includes/specialpage/RedirectSpecialPage.php
index 2e6e55a7..5047354e 100644
--- a/includes/specialpage/RedirectSpecialPage.php
+++ b/includes/specialpage/RedirectSpecialPage.php
@@ -33,8 +33,11 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage {
// Query parameters added by redirects
protected $mAddedRedirectParams = array();
- public function execute( $par ) {
- $redirect = $this->getRedirect( $par );
+ /**
+ * @param string|null $subpage
+ */
+ public function execute( $subpage ) {
+ $redirect = $this->getRedirect( $subpage );
$query = $this->getRedirectQuery();
// Redirect to a page title with possible query parameters
if ( $redirect instanceof Title ) {
@@ -58,22 +61,24 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage {
* If the special page is a redirect, then get the Title object it redirects to.
* False otherwise.
*
- * @param string $par Subpage string
+ * @param string|null $subpage
* @return Title|bool
*/
- abstract public function getRedirect( $par );
+ abstract public function getRedirect( $subpage );
/**
* Return part of the request string for a special redirect page
* This allows passing, e.g. action=history to Special:Mypage, etc.
*
- * @return string
+ * @return array|bool
*/
public function getRedirectQuery() {
$params = array();
$request = $this->getRequest();
- foreach ( $this->mAllowedRedirectParams as $arg ) {
+ foreach ( array_merge( $this->mAllowedRedirectParams,
+ array( 'uselang', 'useskin', 'debug' ) // parameters which can be passed to all pages
+ ) as $arg ) {
if ( $request->getVal( $arg, null ) !== null ) {
$params[$arg] = $request->getVal( $arg );
} elseif ( $request->getArray( $arg, null ) !== null ) {
@@ -89,6 +94,18 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage {
? $params
: false;
}
+
+ /**
+ * Indicate if the target of this redirect can be used to identify
+ * a particular user of this wiki (e.g., if the redirect is to the
+ * user page of a User). See T109724.
+ *
+ * @since 1.27
+ * @return bool
+ */
+ public function personallyIdentifiableTarget() {
+ return false;
+ }
}
/**
@@ -112,12 +129,16 @@ abstract class SpecialRedirectToSpecial extends RedirectSpecialPage {
$this->mAddedRedirectParams = $addedRedirectParams;
}
+ /**
+ * @param string|null $subpage
+ * @return Title|bool
+ */
public function getRedirect( $subpage ) {
if ( $this->redirSubpage === false ) {
return SpecialPage::getTitleFor( $this->redirName, $subpage );
- } else {
- return SpecialPage::getTitleFor( $this->redirName, $this->redirSubpage );
}
+
+ return SpecialPage::getTitleFor( $this->redirName, $this->redirSubpage );
}
}
@@ -140,11 +161,11 @@ abstract class SpecialRedirectToSpecial extends RedirectSpecialPage {
* - limit, offset: Useful for linking to history of one's own user page or
* user talk page. For example, this would be a link to "the last edit to your
* user talk page in the year 2010":
- * http://en.wikipedia.org/wiki/Special:MyPage?offset=20110000000000&limit=1&action=history
+ * https://en.wikipedia.org/wiki/Special:MyPage?offset=20110000000000&limit=1&action=history
*
* - feed: would allow linking to the current user's RSS feed for their user
* talk page:
- * http://en.wikipedia.org/w/index.php?title=Special:MyTalk&action=history&feed=rss
+ * https://en.wikipedia.org/w/index.php?title=Special:MyTalk&action=history&feed=rss
*
* - preloadtitle: Can be used to provide a default section title for a
* preloaded new comment on one's own talk page.
@@ -159,7 +180,7 @@ abstract class SpecialRedirectToSpecial extends RedirectSpecialPage {
* - redlink: Affects the message the user sees if their talk page/user talk
* page does not currently exist. Avoids confusion for newbies with no user
* pages over why they got a "permission error" following this link:
- * http://en.wikipedia.org/w/index.php?title=Special:MyPage&redlink=1
+ * https://en.wikipedia.org/w/index.php?title=Special:MyPage&redlink=1
*
* - debug: determines whether the debug parameter is passed to load.php,
* which disables reformatting and allows scripts to be debugged. Useful
@@ -198,7 +219,7 @@ abstract class RedirectSpecialArticle extends RedirectSpecialPage {
'section', 'oldid', 'diff', 'dir',
'limit', 'offset', 'feed',
# Misc options
- 'redlink', 'debug',
+ 'redlink',
# Options for action=raw; missing ctype can break JS or CSS in some browsers
'ctype', 'maxage', 'smaxage',
);
diff --git a/includes/specialpage/SpecialPage.php b/includes/specialpage/SpecialPage.php
index a7a43b0e..65a4eb9a 100644
--- a/includes/specialpage/SpecialPage.php
+++ b/includes/specialpage/SpecialPage.php
@@ -662,7 +662,6 @@ class SpecialPage {
*/
public function getFinalGroupName() {
$name = $this->getName();
- $specialPageGroups = $this->getConfig()->get( 'SpecialPageGroups' );
// Allow overbidding the group from the wiki side
$msg = $this->msg( 'specialpages-specialpagegroup-' . strtolower( $name ) )->inContentLanguage();
@@ -671,18 +670,6 @@ class SpecialPage {
} else {
// Than use the group from this object
$group = $this->getGroupName();
-
- // Group '-' is used as default to have the chance to determine,
- // if the special pages overrides this method,
- // if not overridden, $wgSpecialPageGroups is checked for b/c
- if ( $group === '-' && isset( $specialPageGroups[$name] ) ) {
- $group = $specialPageGroups[$name];
- }
- }
-
- // never give '-' back, change to 'other'
- if ( $group === '-' ) {
- $group = 'other';
}
return $group;
@@ -697,8 +684,16 @@ class SpecialPage {
* @since 1.21
*/
protected function getGroupName() {
- // '-' used here to determine, if this group is overridden or has a hardcoded 'other'
- // Needed for b/c in getFinalGroupName
- return '-';
+ return 'other';
+ }
+
+ /**
+ * Call wfTransactionalTimeLimit() if this request was POSTed
+ * @since 1.26
+ */
+ protected function useTransactionalTimeLimit() {
+ if ( $this->getRequest()->wasPosted() ) {
+ wfTransactionalTimeLimit();
+ }
}
}
diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php
index dedfcb6a..e794a5df 100644
--- a/includes/specialpage/SpecialPageFactory.php
+++ b/includes/specialpage/SpecialPageFactory.php
@@ -218,7 +218,7 @@ class SpecialPageFactory {
global $wgSpecialPages;
global $wgDisableInternalSearch, $wgEmailAuthentication;
global $wgEnableEmail, $wgEnableJavaScriptTest;
- global $wgPageLanguageUseDB;
+ global $wgPageLanguageUseDB, $wgContentHandlerUseDB;
if ( !is_array( self::$list ) ) {
@@ -244,6 +244,9 @@ class SpecialPageFactory {
if ( $wgPageLanguageUseDB ) {
self::$list['PageLanguage'] = 'SpecialPageLanguage';
}
+ if ( $wgContentHandlerUseDB ) {
+ self::$list['ChangeContentModel'] = 'SpecialChangeContentModel';
+ }
self::$list['Activeusers'] = 'SpecialActiveUsers';
@@ -260,14 +263,13 @@ class SpecialPageFactory {
}
/**
- * Initialise and return the list of special page aliases. Returns an object with
- * properties which can be accessed $obj->pagename - each property name is an
- * alias, with the value being the canonical name of the special page. All
- * registered special pages are guaranteed to map to themselves.
- * @return object
+ * Initialise and return the list of special page aliases. Returns an array where
+ * the key is an alias, and the value is the canonical name of the special page.
+ * All registered special pages are guaranteed to map to themselves.
+ * @return array
*/
- private static function getAliasListObject() {
- if ( !is_object( self::$aliases ) ) {
+ private static function getAliasList() {
+ if ( is_null( self::$aliases ) ) {
global $wgContLang;
$aliases = $wgContLang->getSpecialPageAliases();
$pageList = self::getPageList();
@@ -310,9 +312,6 @@ class SpecialPageFactory {
}
}
}
-
- // Cast to object: func()[$key] doesn't work, but func()->$key does
- self::$aliases = (object)self::$aliases;
}
return self::$aliases;
@@ -332,8 +331,9 @@ class SpecialPageFactory {
$caseFoldedAlias = $wgContLang->caseFold( $bits[0] );
$caseFoldedAlias = str_replace( ' ', '_', $caseFoldedAlias );
- if ( isset( self::getAliasListObject()->$caseFoldedAlias ) ) {
- $name = self::getAliasListObject()->$caseFoldedAlias;
+ $aliases = self::getAliasList();
+ if ( isset( $aliases[$caseFoldedAlias] ) ) {
+ $name = $aliases[$caseFoldedAlias];
} else {
return array( null, null );
}
@@ -348,34 +348,6 @@ class SpecialPageFactory {
}
/**
- * Add a page to a certain display group for Special:SpecialPages
- *
- * @param SpecialPage|string $page
- * @param string $group
- * @deprecated since 1.21 Override SpecialPage::getGroupName
- */
- public static function setGroup( $page, $group ) {
- wfDeprecated( __METHOD__, '1.21' );
-
- global $wgSpecialPageGroups;
- $name = is_object( $page ) ? $page->getName() : $page;
- $wgSpecialPageGroups[$name] = $group;
- }
-
- /**
- * Get the group that the special page belongs in on Special:SpecialPage
- *
- * @param SpecialPage $page
- * @return string
- * @deprecated since 1.21 Use SpecialPage::getFinalGroupName
- */
- public static function getGroup( &$page ) {
- wfDeprecated( __METHOD__, '1.21' );
-
- return $page->getFinalGroupName();
- }
-
- /**
* Check if a given name exist as a special page or as a special page alias
*
* @param string $name Name of a special page
@@ -572,7 +544,6 @@ class SpecialPageFactory {
$context->setTitle( $page->getPageTitle( $par ) );
}
} elseif ( !$page->isIncludable() ) {
-
return false;
}
@@ -638,7 +609,7 @@ class SpecialPageFactory {
public static function getLocalNameFor( $name, $subpage = false ) {
global $wgContLang;
$aliases = $wgContLang->getSpecialPageAliases();
- $aliasList = self::getAliasListObject();
+ $aliasList = self::getAliasList();
// Find the first alias that maps back to $name
if ( isset( $aliases[$name] ) ) {
@@ -646,8 +617,8 @@ class SpecialPageFactory {
foreach ( $aliases[$name] as $alias ) {
$caseFoldedAlias = $wgContLang->caseFold( $alias );
$caseFoldedAlias = str_replace( ' ', '_', $caseFoldedAlias );
- if ( isset( $aliasList->$caseFoldedAlias ) &&
- $aliasList->$caseFoldedAlias === $name
+ if ( isset( $aliasList[$caseFoldedAlias] ) &&
+ $aliasList[$caseFoldedAlias] === $name
) {
$name = $alias;
$found = true;