Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -4986,12 +4986,6 @@ |
4987 | 4987 | $wgSortSpecialPages = true; |
4988 | 4988 | |
4989 | 4989 | /** |
4990 | | - * Filter for Special:Randompage. Part of a WHERE clause |
4991 | | - * @deprecated as of 1.16, use the SpecialRandomGetRandomTitle hook |
4992 | | - */ |
4993 | | -$wgExtraRandompageSQL = false; |
4994 | | - |
4995 | | -/** |
4996 | 4990 | * On Special:Unusedimages, consider images "used", if they are put |
4997 | 4991 | * into a category. Default (false) is not to count those as used. |
4998 | 4992 | */ |
Index: trunk/phase3/includes/specials/SpecialRandompage.php |
— | — | @@ -126,13 +126,8 @@ |
127 | 127 | } |
128 | 128 | |
129 | 129 | protected function getQueryInfo( $randstr ) { |
130 | | - global $wgExtraRandompageSQL; |
131 | 130 | $redirect = $this->isRedirect() ? 1 : 0; |
132 | 131 | |
133 | | - if ( $wgExtraRandompageSQL ) { |
134 | | - $this->extra[] = $wgExtraRandompageSQL; |
135 | | - } |
136 | | - |
137 | 132 | return array( |
138 | 133 | 'tables' => array( 'page' ), |
139 | 134 | 'fields' => array( 'page_title', 'page_namespace' ), |
Index: trunk/extensions/Randomrootpage/Randomrootpage_body.php |
— | — | @@ -1,97 +1,15 @@ |
2 | 2 | <?php |
3 | 3 | if (!defined('MEDIAWIKI')) die(); |
4 | 4 | |
5 | | -class SpecialRandomrootpage extends SpecialPage { |
| 5 | +class SpecialRandomrootpage extends RandomPage { |
6 | 6 | |
7 | 7 | public function __construct() { |
8 | 8 | parent::__construct( 'Randomrootpage' ); |
| 9 | + $this->extra[] = "page_title NOT LIKE '%/%'"; |
9 | 10 | } |
10 | 11 | |
11 | | - private $namespace = NS_MAIN; // namespace to select pages from |
12 | | - |
13 | | - public function getNamespace() { |
14 | | - return $this->namespace; |
15 | | - } |
16 | | - |
17 | | - public function setNamespace ( $ns ) { |
18 | | - if( $ns < NS_MAIN ) $ns = NS_MAIN; |
19 | | - $this->namespace = $ns; |
20 | | - } |
21 | | - |
22 | 12 | // Don't select redirects |
23 | 13 | public function isRedirect(){ |
24 | 14 | return false; |
25 | 15 | } |
26 | | - |
27 | | - public function execute( $par ) { |
28 | | - global $wgOut, $wgContLang; |
29 | | - |
30 | | - |
31 | | - |
32 | | - if ($par) |
33 | | - $this->setNamespace( $wgContLang->getNsIndex( $par ) ); |
34 | | - |
35 | | - $title = $this->getRandomTitle(); |
36 | | - |
37 | | - if( is_null( $title ) ) { |
38 | | - $this->setHeaders(); |
39 | | - $wgOut->addWikiMsg( strtolower( $this->mName ) . '-nopages' ); |
40 | | - return; |
41 | | - } |
42 | | - |
43 | | - $query = $this->isRedirect() ? 'redirect=no' : ''; |
44 | | - $wgOut->redirect( $title->getFullUrl( $query ) ); |
45 | | - } |
46 | | - |
47 | | - |
48 | | - /** |
49 | | - * Choose a random title. |
50 | | - * @return Title object (or null if nothing to choose from) |
51 | | - */ |
52 | | - public function getRandomTitle() { |
53 | | - $randstr = wfRandom(); |
54 | | - $row = $this->selectRandomPageFromDB( $randstr ); |
55 | | - |
56 | | - /* If we picked a value that was higher than any in |
57 | | - * the DB, wrap around and select the page with the |
58 | | - * lowest value instead! One might think this would |
59 | | - * skew the distribution, but in fact it won't cause |
60 | | - * any more bias than what the page_random scheme |
61 | | - * causes anyway. Trust me, I'm a mathematician. :) |
62 | | - */ |
63 | | - if( !$row ) |
64 | | - $row = $this->selectRandomPageFromDB( "0" ); |
65 | | - |
66 | | - if( $row ) |
67 | | - return Title::makeTitleSafe( $this->namespace, $row->page_title ); |
68 | | - else |
69 | | - return null; |
70 | | - } |
71 | | - |
72 | | - private function selectRandomPageFromDB( $randstr ) { |
73 | | - global $wgExtraRandompageSQL; |
74 | | - $fname = 'RandomPage::selectRandomPageFromDB'; |
75 | | - |
76 | | - $dbr = wfGetDB( DB_SLAVE ); |
77 | | - |
78 | | - $use_index = $dbr->useIndexClause( 'page_random' ); |
79 | | - $page = $dbr->tableName( 'page' ); |
80 | | - |
81 | | - $ns = (int) $this->namespace; |
82 | | - $redirect = $this->isRedirect() ? 1 : 0; |
83 | | - |
84 | | - $extra = $wgExtraRandompageSQL ? "AND ($wgExtraRandompageSQL)" : ""; |
85 | | - $sql = "SELECT page_title |
86 | | - FROM $page $use_index |
87 | | - WHERE page_namespace = $ns |
88 | | - AND page_is_redirect = $redirect |
89 | | - AND page_random >= $randstr |
90 | | - AND page_title NOT LIKE '%/%' |
91 | | - $extra |
92 | | - ORDER BY page_random"; |
93 | | - |
94 | | - $sql = $dbr->limitResult( $sql, 1, 0 ); |
95 | | - $res = $dbr->query( $sql, $fname ); |
96 | | - return $dbr->fetchObject( $res ); |
97 | | - } |
98 | 16 | } |
Index: trunk/extensions/PureWikiDeletion/SpecialPureWikiDeletion.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | * @license GNU General Public Licence 2.0 or later |
11 | 11 | * @modified by Tisane |
12 | 12 | */ |
13 | | -class RandomExcludeBlank extends SpecialPage { |
| 13 | +class RandomExcludeBlank extends RandomPage { |
14 | 14 | private $namespaces; // namespaces to select pages from |
15 | 15 | function __construct( $name = 'RandomExcludeBlank' ){ |
16 | 16 | global $wgContentNamespaces; |
— | — | @@ -17,19 +17,9 @@ |
18 | 18 | $this->namespaces = $wgContentNamespaces; |
19 | 19 | |
20 | 20 | parent::__construct( $name ); |
21 | | - $this->setGroup('RandomExcludeBlank' |
22 | | - ,'redirects'); |
| 21 | + SpecialPageFactory::setGroup( 'RandomExcludeBlank','redirects' ); |
23 | 22 | } |
24 | 23 | |
25 | | - public function getNamespaces() { |
26 | | - return $this->namespaces; |
27 | | - } |
28 | | - |
29 | | - public function setNamespace ( $ns ) { |
30 | | - if( !$ns || $ns < NS_MAIN ) $ns = NS_MAIN; |
31 | | - $this->namespaces = array( $ns ); |
32 | | - } |
33 | | - |
34 | 24 | // select redirects instead of normal pages? |
35 | 25 | // Overriden by SpecialRandomredirect |
36 | 26 | public function isRedirect(){ |
— | — | @@ -39,8 +29,9 @@ |
40 | 30 | public function execute( $par ) { |
41 | 31 | global $wgOut, $wgContLang; |
42 | 32 | |
43 | | - if ($par) |
| 33 | + if ($par) { |
44 | 34 | $this->setNamespace( $wgContLang->getNsIndex( $par ) ); |
| 35 | + } |
45 | 36 | |
46 | 37 | $isBlank=true; |
47 | 38 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -48,7 +39,7 @@ |
49 | 40 | $title = $this->getRandomTitle(); |
50 | 41 | $result=$dbr->selectRow('blanked_page','blank_page_id' |
51 | 42 | ,array("blank_page_id" => $title->getArticleID())); |
52 | | - if (!$result && !$title->isRedirect()){ |
| 43 | + if ( !$result && !$title->isRedirect() ) { |
53 | 44 | $isBlank=false; |
54 | 45 | } |
55 | 46 | } |
— | — | @@ -62,58 +53,6 @@ |
63 | 54 | $query = $this->isRedirect() ? 'redirect=no' : ''; |
64 | 55 | $wgOut->redirect( $title->getFullUrl( $query ) ); |
65 | 56 | } |
66 | | - |
67 | | - |
68 | | - /** |
69 | | - * Choose a random title. |
70 | | - * @return Title object (or null if nothing to choose from) |
71 | | - */ |
72 | | - public function getRandomTitle() { |
73 | | - |
74 | | - $randstr = wfRandom(); |
75 | | - $row = $this->selectRandomPageFromDB( $randstr ); |
76 | | - |
77 | | - /* If we picked a value that was higher than any in |
78 | | - * the DB, wrap around and select the page with the |
79 | | - * lowest value instead! One might think this would |
80 | | - * skew the distribution, but in fact it won't cause |
81 | | - * any more bias than what the page_random scheme |
82 | | - * causes anyway. Trust me, I'm a mathematician. :) |
83 | | - */ |
84 | | - if( !$row ) |
85 | | - $row = $this->selectRandomPageFromDB( "0" ); |
86 | | - |
87 | | - if( $row ) |
88 | | - return Title::makeTitleSafe( $row->page_namespace, $row->page_title ); |
89 | | - else |
90 | | - return null; |
91 | | - } |
92 | | - |
93 | | - private function selectRandomPageFromDB( $randstr ) { |
94 | | - global $wgExtraRandompageSQL; |
95 | | - $fname = 'RandomPage::selectRandomPageFromDB'; |
96 | | - |
97 | | - $dbr = wfGetDB( DB_SLAVE ); |
98 | | - |
99 | | - $use_index = $dbr->useIndexClause( 'page_random' ); |
100 | | - $page = $dbr->tableName( 'page' ); |
101 | | - |
102 | | - $ns = implode( ",", $this->namespaces ); |
103 | | - $redirect = $this->isRedirect() ? 1 : 0; |
104 | | - |
105 | | - $extra = $wgExtraRandompageSQL ? "AND ($wgExtraRandompageSQL)" : ""; |
106 | | - $sql = "SELECT page_title, page_namespace |
107 | | - FROM $page $use_index |
108 | | - WHERE page_namespace IN ( $ns ) |
109 | | - AND page_is_redirect = $redirect |
110 | | - AND page_random >= $randstr |
111 | | - $extra |
112 | | - ORDER BY page_random"; |
113 | | - |
114 | | - $sql = $dbr->limitResult( $sql, 1, 0 ); |
115 | | - $res = $dbr->query( $sql, $fname ); |
116 | | - return $dbr->fetchObject( $res ); |
117 | | - } |
118 | 57 | } |
119 | 58 | |
120 | 59 | /** |