From 86b022c2bde20dbc0945d43e12c7aad73698e709 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 10 Aug 2009 20:44:31 +0000 Subject: [PATCH] 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. --- RELEASE-NOTES | 5 ----- docs/hooks.txt | 10 ---------- includes/DefaultSettings.php | 5 +---- includes/specials/SpecialRandompage.php | 23 ++++++++++------------- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c0e50607e1..92d8090717 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -79,8 +79,6 @@ this. Was used when mwEmbed was going to be an extension. to control which external domains may access the API via cross-site AJAX. * $wgMaintenanceScripts for extensions to add their scripts to the default list * $wgMemoryLimit has been added, default value '50M' -* $wgExtraRandompageSQL is deprecated, the SpecialRandomBeforeSQL hook should - be used instead === New features in 1.16 === @@ -194,9 +192,6 @@ this. Was used when mwEmbed was going to be an extension. numbers outside the permitted ranges), etc. ** The summary attribute has been removed from tables of contents. summary is obsolete in HTML 5 and wasn't useful here anyway. -* New hook SpecialRandomBeforeSQL allows extensions to modify or replace the SQL - query used in Special:Random and subclasses, deprecating the $wgExtraRandompageSQL - config variable === Bug fixes in 1.16 === diff --git a/docs/hooks.txt b/docs/hooks.txt index fdeaa61ff2..5ec31d9717 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1368,16 +1368,6 @@ $newTitle: new title (object) hook to remove a core special page $list: list (array) of core special pages -'SpecialRandomBeforeSQL': called before building the SQL statement for -Special:Random and all subclasses -$page: The RandomPage object -&$ns: Comma separated list of namespaces used in the query -&$redirect: 1 or 0, whether to retrieve a redirect or a non-redirect -&$extra: Extra SQL statements in the WHERE clause, after checking -$wgExtraRandompageSQL and after subclasses add extra clauses -&$sql: The query used if the hook returns false, must select -page_namespace and page_title - 'SpecialRecentChangesPanel': called when building form options in SpecialRecentChanges &$extraOpts: array of added items, to which can be added diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index fbcb864560..08ac119e9b 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2809,10 +2809,7 @@ $wgUseSiteJs = true; /** Use the site's Cascading Style Sheets (CSS)? */ $wgUseSiteCss = true; -/** - * Filter for Special:Randompage. Part of a WHERE clause - * @deprecated as of 1.16, use the SpecialRandomBeforeSQL hook -*/ +/** Filter for Special:Randompage. Part of a WHERE clause */ $wgExtraRandompageSQL = false; /** Allow the "info" action, very inefficient at the moment */ diff --git a/includes/specials/SpecialRandompage.php b/includes/specials/SpecialRandompage.php index 401050578a..af43e9c605 100644 --- a/includes/specials/SpecialRandompage.php +++ b/includes/specials/SpecialRandompage.php @@ -89,23 +89,20 @@ class RandomPage extends SpecialPage { $extra = $wgExtraRandompageSQL ? "AND ($wgExtraRandompageSQL)" : ""; $extra .= $this->addExtraSQL() ? "AND (".$this->addExtraSQL().")" : ""; - $sql = ''; - if ( wfRunHooks( 'SpecialRandomBeforeSQL', array( $this, &$ns, &$redirect, &$extra, &$sql ) ) ) { - $sql = "SELECT page_title, page_namespace - FROM $page $use_index - WHERE page_namespace IN ( $ns ) - AND page_is_redirect = $redirect - AND page_random >= $randstr - $extra - ORDER BY page_random"; - - $sql = $dbr->limitResult( $sql, 1, 0 ); - } + $sql = "SELECT page_title, page_namespace + FROM $page $use_index + WHERE page_namespace IN ( $ns ) + AND page_is_redirect = $redirect + AND page_random >= $randstr + $extra + ORDER BY page_random"; + + $sql = $dbr->limitResult( $sql, 1, 0 ); $res = $dbr->query( $sql, __METHOD__ ); return $dbr->fetchObject( $res ); } - // an alternative to $wgExtraRandompageSQL so subclasses + // an alternative to $wgExtraRandompageSQL so extensions // can add their own SQL by overriding this function public function addExtraSQL() { return ''; -- 2.20.1