r45467 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45466‎ | r45467 | r45468 >
Date:23:25, 6 January 2009
Author:siebrand
Status:ok
Tags:
Comment:
(bug 16560) Special:Random returns a page from ContentNamespaces, and no longer from NS_MAIN. Patch contributed by Lucas Garczewski.
Modified paths:
  • /trunk/phase3/CREDITS (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRandompage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/CREDITS
@@ -63,6 +63,7 @@
6464 * Happy-melon
6565 * Jeremy Baron
6666 * Juliano F. Ravasi
 67+* Lucas Garczewski
6768 * Louperivois
6869 * Marooned
6970 * Max Semenik
Index: trunk/phase3/includes/specials/SpecialRandompage.php
@@ -8,19 +8,23 @@
99 * @license GNU General Public Licence 2.0 or later
1010 */
1111 class RandomPage extends SpecialPage {
12 - private $namespace = NS_MAIN; // namespace to select pages from
 12+ private $namespaces; // namespaces to select pages from
1313
1414 function __construct( $name = 'Randompage' ){
 15+ global $wgContentNamespaces;
 16+
 17+ $this->namespaces = $wgContentNamespaces;
 18+
1519 parent::__construct( $name );
1620 }
1721
18 - public function getNamespace() {
19 - return $this->namespace;
 22+ public function getNamespaces() {
 23+ return $this->namespaces;
2024 }
2125
2226 public function setNamespace ( $ns ) {
2327 if( $ns < NS_MAIN ) $ns = NS_MAIN;
24 - $this->namespace = $ns;
 28+ $this->namespaces = array( $ns );
2529 }
2630
2731 // select redirects instead of normal pages?
@@ -67,7 +71,7 @@
6872 $row = $this->selectRandomPageFromDB( "0" );
6973
7074 if( $row )
71 - return Title::makeTitleSafe( $this->namespace, $row->page_title );
 75+ return Title::makeTitleSafe( $row->page_namespace, $row->page_title );
7276 else
7377 return null;
7478 }
@@ -81,13 +85,13 @@
8286 $use_index = $dbr->useIndexClause( 'page_random' );
8387 $page = $dbr->tableName( 'page' );
8488
85 - $ns = (int) $this->namespace;
 89+ $ns = implode( ",", $this->namespaces );
8690 $redirect = $this->isRedirect() ? 1 : 0;
8791
8892 $extra = $wgExtraRandompageSQL ? "AND ($wgExtraRandompageSQL)" : "";
89 - $sql = "SELECT page_title
 93+ $sql = "SELECT page_title, page_namespace
9094 FROM $page $use_index
91 - WHERE page_namespace = $ns
 95+ WHERE page_namespace IN ( $ns )
9296 AND page_is_redirect = $redirect
9397 AND page_random >= $randstr
9498 $extra
Index: trunk/phase3/RELEASE-NOTES
@@ -71,7 +71,7 @@
7272 * The 'BeforeWatchlist' hook has been removed due to internal changes in
7373 Special:Watchlist. 'SpecialWatchlistQuery' should now be used by extensions
7474 to customize the watchlist database query.
75 -* Added $wgNewPasswordExpiry, to specify an expiry time (in seconds) to
 75+* Added $wgNewPasswordExpiry, to specify an expiry time (in seconds) to
7676 tempoary passwords
7777
7878 === Migrated extensions ===
@@ -221,7 +221,7 @@
222222 * Moved password reset form from Special:Preferences to Special:ResetPass
223223 * Added Special:ChangePassword as a special page alias for Special:ResetPass
224224 * Added complimentary function for addHandler() called removeHandler() for removing events
225 -* Improved security of file uploads for IE clients, using a reverse-engineered
 225+* Improved security of file uploads for IE clients, using a reverse-engineered
226226 algorithm very similar to IE's content detection algorithm.
227227 * Cascading protection no longer requires that both edit and move are restricted
228228 to sysop, just edit=sysop is enough
@@ -230,7 +230,7 @@
231231 has been updated, and the 1.3 URL has been given. 1.2 is still Wikipedia-compatible.
232232 RightsCode was changed from 'gfdl' to 'gfdl1_2', so we can now support 1.2 as well
233233 as 1.3 (gfdl1_3).
234 -* (bug 16293) PD URL was changed to the CreativeCommons site on PD (which auto-detects
 234+* (bug 16293) PD URL was changed to the CreativeCommons site on PD (which auto-detects
235235 your language) instead of Wikipedia.
236236 * (bug 16635) The "view and edit watchlist" page (Special:Watchlist/edit) now
237237 includes a table of contents
@@ -425,7 +425,7 @@
426426 had marked them as having created another account, when their last account
427427 creation had actually failed.
428428 * (bug 12647) Allow autogenerated edit summary messages to be blanked with '-'
429 -* (bug 16026) 'Revision-info' and 'revision-info-current' both accept wiki
 429+* (bug 16026) 'Revision-info' and 'revision-info-current' both accept wiki
430430 markup now.
431431 * (bug 16529) Fix for search suggestions with some third-party JS libraries
432432 * (bug 13342) importScript() generates more consistent URI encoding
@@ -441,7 +441,7 @@
442442 * (bug 5506) Links to files on foreign repositories are now shown consistently
443443 as bluelinks e.g. in logs and edit summaries
444444 * (bug 16623) Add missing </p> tag in Special:LockDB
445 -* (bug 15849) Special:Movepage now throws a more specific error when trying to
 445+* (bug 15849) Special:Movepage now throws a more specific error when trying to
446446 move a title to an interwiki target
447447 * (bug 16638) 8-bit URL fallback encoding now set on additional languages using
448448 Arabic script (Persian, Urdu, Sindhi, Punjabi)
@@ -471,6 +471,8 @@
472472 that STDIN can be used for page list
473473 * Sanitizer::decodeCharReferences() now decodes the XHTML "&apos;" character
474474 entity (loosely related to bug 14365)
 475+* (bug 16560) Special:Random returns a page from ContentNamespaces, and no
 476+ longer from NS_MAIN
475477
476478 === API changes in 1.14 ===
477479
@@ -570,7 +572,7 @@
571573 * (bug 16515) Added pst and onlypst parameters to action=parse
572574 * (bug 16541) Added block expiry timestamp to list=logevents output
573575 * (bug 16613) action=protect doesn't tell when &cascade was set but cascading
574 - protection wasn't allowed
 576+ protection wasn't allowed
575577 * (bug 16626) action=delete now correctly handles empty "reason" param
576578 * (bug 15579) clshow considers all categories !hidden
577579 * (bug 16647) list=allcategories, prop=categories don't return "hidden"

Status & tagging log