From d02fdec1a21d0b9bbbdafa39925e9789e19ecde7 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Tue, 6 Jan 2009 23:25:03 +0000 Subject: [PATCH] (bug 16560) Special:Random returns a page from ContentNamespaces, and no longer from NS_MAIN. Patch contributed by Lucas Garczewski. --- CREDITS | 1 + RELEASE-NOTES | 14 ++++++++------ includes/specials/SpecialRandompage.php | 20 ++++++++++++-------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/CREDITS b/CREDITS index d9846fb3d3..3702afba3f 100644 --- a/CREDITS +++ b/CREDITS @@ -63,6 +63,7 @@ following names for their contribution to the product. * Happy-melon * Jeremy Baron * Juliano F. Ravasi +* Lucas Garczewski * Louperivois * Marooned * Max Semenik diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a1723cffc1..88df5075e6 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -71,7 +71,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * The 'BeforeWatchlist' hook has been removed due to internal changes in Special:Watchlist. 'SpecialWatchlistQuery' should now be used by extensions to customize the watchlist database query. -* Added $wgNewPasswordExpiry, to specify an expiry time (in seconds) to +* Added $wgNewPasswordExpiry, to specify an expiry time (in seconds) to tempoary passwords === Migrated extensions === @@ -221,7 +221,7 @@ The following extensions are migrated into MediaWiki 1.14: * Moved password reset form from Special:Preferences to Special:ResetPass * Added Special:ChangePassword as a special page alias for Special:ResetPass * Added complimentary function for addHandler() called removeHandler() for removing events -* Improved security of file uploads for IE clients, using a reverse-engineered +* Improved security of file uploads for IE clients, using a reverse-engineered algorithm very similar to IE's content detection algorithm. * Cascading protection no longer requires that both edit and move are restricted to sysop, just edit=sysop is enough @@ -230,7 +230,7 @@ The following extensions are migrated into MediaWiki 1.14: has been updated, and the 1.3 URL has been given. 1.2 is still Wikipedia-compatible. RightsCode was changed from 'gfdl' to 'gfdl1_2', so we can now support 1.2 as well as 1.3 (gfdl1_3). -* (bug 16293) PD URL was changed to the CreativeCommons site on PD (which auto-detects +* (bug 16293) PD URL was changed to the CreativeCommons site on PD (which auto-detects your language) instead of Wikipedia. * (bug 16635) The "view and edit watchlist" page (Special:Watchlist/edit) now includes a table of contents @@ -425,7 +425,7 @@ The following extensions are migrated into MediaWiki 1.14: had marked them as having created another account, when their last account creation had actually failed. * (bug 12647) Allow autogenerated edit summary messages to be blanked with '-' -* (bug 16026) 'Revision-info' and 'revision-info-current' both accept wiki +* (bug 16026) 'Revision-info' and 'revision-info-current' both accept wiki markup now. * (bug 16529) Fix for search suggestions with some third-party JS libraries * (bug 13342) importScript() generates more consistent URI encoding @@ -441,7 +441,7 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 5506) Links to files on foreign repositories are now shown consistently as bluelinks e.g. in logs and edit summaries * (bug 16623) Add missing

tag in Special:LockDB -* (bug 15849) Special:Movepage now throws a more specific error when trying to +* (bug 15849) Special:Movepage now throws a more specific error when trying to move a title to an interwiki target * (bug 16638) 8-bit URL fallback encoding now set on additional languages using Arabic script (Persian, Urdu, Sindhi, Punjabi) @@ -471,6 +471,8 @@ The following extensions are migrated into MediaWiki 1.14: that STDIN can be used for page list * Sanitizer::decodeCharReferences() now decodes the XHTML "'" character entity (loosely related to bug 14365) +* (bug 16560) Special:Random returns a page from ContentNamespaces, and no + longer from NS_MAIN === API changes in 1.14 === @@ -570,7 +572,7 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 16515) Added pst and onlypst parameters to action=parse * (bug 16541) Added block expiry timestamp to list=logevents output * (bug 16613) action=protect doesn't tell when &cascade was set but cascading - protection wasn't allowed + protection wasn't allowed * (bug 16626) action=delete now correctly handles empty "reason" param * (bug 15579) clshow considers all categories !hidden * (bug 16647) list=allcategories, prop=categories don't return "hidden" diff --git a/includes/specials/SpecialRandompage.php b/includes/specials/SpecialRandompage.php index f3f6dec2ef..f4bff30bfd 100644 --- a/includes/specials/SpecialRandompage.php +++ b/includes/specials/SpecialRandompage.php @@ -8,19 +8,23 @@ * @license GNU General Public Licence 2.0 or later */ class RandomPage extends SpecialPage { - private $namespace = NS_MAIN; // namespace to select pages from + private $namespaces; // namespaces to select pages from function __construct( $name = 'Randompage' ){ + global $wgContentNamespaces; + + $this->namespaces = $wgContentNamespaces; + parent::__construct( $name ); } - public function getNamespace() { - return $this->namespace; + public function getNamespaces() { + return $this->namespaces; } public function setNamespace ( $ns ) { if( $ns < NS_MAIN ) $ns = NS_MAIN; - $this->namespace = $ns; + $this->namespaces = array( $ns ); } // select redirects instead of normal pages? @@ -67,7 +71,7 @@ class RandomPage extends SpecialPage { $row = $this->selectRandomPageFromDB( "0" ); if( $row ) - return Title::makeTitleSafe( $this->namespace, $row->page_title ); + return Title::makeTitleSafe( $row->page_namespace, $row->page_title ); else return null; } @@ -81,13 +85,13 @@ class RandomPage extends SpecialPage { $use_index = $dbr->useIndexClause( 'page_random' ); $page = $dbr->tableName( 'page' ); - $ns = (int) $this->namespace; + $ns = implode( ",", $this->namespaces ); $redirect = $this->isRedirect() ? 1 : 0; $extra = $wgExtraRandompageSQL ? "AND ($wgExtraRandompageSQL)" : ""; - $sql = "SELECT page_title + $sql = "SELECT page_title, page_namespace FROM $page $use_index - WHERE page_namespace = $ns + WHERE page_namespace IN ( $ns ) AND page_is_redirect = $redirect AND page_random >= $randstr $extra -- 2.20.1