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 SpecialRandomGetRandomTitle hook
+ should be used instead
=== New features in 1.16 ===
output by omitting some things like quotation marks where HTML 5 allows.
* Added crop for inline images.
* The description message in $wgExtensionCredits can be an array with parameters
+* New hook SpecialRandomGetRandomTitle allows extensions to modify the selection
+ criteria used by Special:Random and subclasses, or substitute a custom result,
+ deprecating the $wgExtraRandompageSQL config variable
=== Bug fixes in 1.16 ===
hook to remove a core special page
$list: list (array) of core special pages
+'SpecialRandomGetRandomTitle': called during the execution of Special:Random,
+use this to change some selection criteria or substitute a different title
+&$randstr: The random number from wfRandom()
+&$isRedir: Boolean, whether to select a redirect or non-redirect
+&$namespaces: An array of namespace indexes to get the title from
+&$extra: An array of extra SQL statements
+&$title: If the hook returns false, a Title object to use instead of the
+result from the normal query
+
'SpecialRecentChangesPanel': called when building form options in
SpecialRecentChanges
&$extraOpts: array of added items, to which can be added
/** Use the site's Cascading Style Sheets (CSS)? */
$wgUseSiteCss = true;
-/** Filter for Special:Randompage. Part of a WHERE clause */
+/**
+ * Filter for Special:Randompage. Part of a WHERE clause
+ * @deprecated as of 1.16, use the SpecialRandomGetRandomTitle hook
+*/
+
$wgExtraRandompageSQL = false;
/** Allow the "info" action, very inefficient at the moment */
*/
class RandomPage extends SpecialPage {
private $namespaces; // namespaces to select pages from
+ protected $isRedir = false; // should the result be a redirect?
+ protected $extra = array(); // Extra SQL statements
public function __construct( $name = 'Randompage' ){
global $wgContentNamespaces;
}
// select redirects instead of normal pages?
- // Overriden by SpecialRandomredirect
public function isRedirect(){
- return false;
+ return $this->isRedir;
}
public function execute( $par ) {
*/
public function getRandomTitle() {
$randstr = wfRandom();
+ $title = null;
+ if ( !wfRunHooks( 'SpecialRandomGetRandomTitle', array( &$randstr, &$this->isRedir, &$this->namespaces, &$this->extra, &$title ) ) ) {
+ return $title;
+ }
$row = $this->selectRandomPageFromDB( $randstr );
/* If we picked a value that was higher than any in
$ns = implode( ",", $this->namespaces );
$redirect = $this->isRedirect() ? 1 : 0;
-
- $extra = $wgExtraRandompageSQL ? "AND ($wgExtraRandompageSQL)" : "";
- $extra .= $this->addExtraSQL() ? "AND (".$this->addExtraSQL().")" : "";
+
+ if ( $wgExtraRandompageSQL ) {
+ $this->extra[] = $wgExtraRandompageSQL;
+ }
+ if ( $this->addExtraSQL() ) {
+ $this->extra[] = $this->addExtraSQL();
+ }
+ $extra = '';
+ if ( $this->extra ) {
+ $extra = 'AND (' . implode( ') AND (', $this->extra ) . ')';
+ }
$sql = "SELECT page_title, page_namespace
FROM $page $use_index
WHERE page_namespace IN ( $ns )
return $dbr->fetchObject( $res );
}
- // an alternative to $wgExtraRandompageSQL so extensions
- // can add their own SQL by overriding this function
+ /* an alternative to $wgExtraRandompageSQL so subclasses
+ * can add their own SQL by overriding this function
+ * @deprecated, append to $this->extra instead
+ */
public function addExtraSQL() {
return '';
}
class SpecialRandomredirect extends RandomPage {
function __construct(){
parent::__construct( 'Randomredirect' );
+ $this->isRedir = true;
}
- // Override parent::isRedirect()
- public function isRedirect(){
- return true;
- }
}