r54739 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54738‎ | r54739 | r54740 >
Date:20:44, 10 August 2009
Author:brion
Status:ok
Tags:
Comment:
Revert r54638 "Deprecate the $wgExtraRandompageSQL config variable by adding a hook, SpecialRandomBeforeSQL"
If we're going to make a generalizable plug-in point for extensions to supply their own randomization, we shouldn't be exposing it at the point of low-level database operations. The extension should instead be given the chance to pick an item any way it pleases and return a result or set of results to choose from.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRandompage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -1368,16 +1368,6 @@
13691369 hook to remove a core special page
13701370 $list: list (array) of core special pages
13711371
1372 -'SpecialRandomBeforeSQL': called before building the SQL statement for
1373 -Special:Random and all subclasses
1374 -$page: The RandomPage object
1375 -&$ns: Comma separated list of namespaces used in the query
1376 -&$redirect: 1 or 0, whether to retrieve a redirect or a non-redirect
1377 -&$extra: Extra SQL statements in the WHERE clause, after checking
1378 -$wgExtraRandompageSQL and after subclasses add extra clauses
1379 -&$sql: The query used if the hook returns false, must select
1380 -page_namespace and page_title
1381 -
13821372 'SpecialRecentChangesPanel': called when building form options in
13831373 SpecialRecentChanges
13841374 &$extraOpts: array of added items, to which can be added
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2809,10 +2809,7 @@
28102810 /** Use the site's Cascading Style Sheets (CSS)? */
28112811 $wgUseSiteCss = true;
28122812
2813 -/**
2814 - * Filter for Special:Randompage. Part of a WHERE clause
2815 - * @deprecated as of 1.16, use the SpecialRandomBeforeSQL hook
2816 -*/
 2813+/** Filter for Special:Randompage. Part of a WHERE clause */
28172814 $wgExtraRandompageSQL = false;
28182815
28192816 /** Allow the "info" action, very inefficient at the moment */
Index: trunk/phase3/includes/specials/SpecialRandompage.php
@@ -89,23 +89,20 @@
9090
9191 $extra = $wgExtraRandompageSQL ? "AND ($wgExtraRandompageSQL)" : "";
9292 $extra .= $this->addExtraSQL() ? "AND (".$this->addExtraSQL().")" : "";
93 - $sql = '';
94 - if ( wfRunHooks( 'SpecialRandomBeforeSQL', array( $this, &$ns, &$redirect, &$extra, &$sql ) ) ) {
95 - $sql = "SELECT page_title, page_namespace
96 - FROM $page $use_index
97 - WHERE page_namespace IN ( $ns )
98 - AND page_is_redirect = $redirect
99 - AND page_random >= $randstr
100 - $extra
101 - ORDER BY page_random";
 93+ $sql = "SELECT page_title, page_namespace
 94+ FROM $page $use_index
 95+ WHERE page_namespace IN ( $ns )
 96+ AND page_is_redirect = $redirect
 97+ AND page_random >= $randstr
 98+ $extra
 99+ ORDER BY page_random";
102100
103 - $sql = $dbr->limitResult( $sql, 1, 0 );
104 - }
 101+ $sql = $dbr->limitResult( $sql, 1, 0 );
105102 $res = $dbr->query( $sql, __METHOD__ );
106103 return $dbr->fetchObject( $res );
107104 }
108105
109 - // an alternative to $wgExtraRandompageSQL so subclasses
 106+ // an alternative to $wgExtraRandompageSQL so extensions
110107 // can add their own SQL by overriding this function
111108 public function addExtraSQL() {
112109 return '';
Index: trunk/phase3/RELEASE-NOTES
@@ -79,8 +79,6 @@
8080 to control which external domains may access the API via cross-site AJAX.
8181 * $wgMaintenanceScripts for extensions to add their scripts to the default list
8282 * $wgMemoryLimit has been added, default value '50M'
83 -* $wgExtraRandompageSQL is deprecated, the SpecialRandomBeforeSQL hook should
84 - be used instead
8583
8684 === New features in 1.16 ===
8785
@@ -194,9 +192,6 @@
195193 numbers outside the permitted ranges), etc.
196194 ** The summary attribute has been removed from tables of contents. summary is
197195 obsolete in HTML 5 and wasn't useful here anyway.
198 -* New hook SpecialRandomBeforeSQL allows extensions to modify or replace the SQL
199 - query used in Special:Random and subclasses, deprecating the $wgExtraRandompageSQL
200 - config variable
201196
202197 === Bug fixes in 1.16 ===
203198

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r54638Deprecate the $wgExtraRandompageSQL config variable by adding a hook, Special...mrzman19:09, 8 August 2009

Status & tagging log