that won't deplete openssl's entropy pool.
* ResourceLoader: File modules can now provide a skip function that uses an
inline feature test to bypass loading of the module.
+* (bug 20210) Special pages may now provide autocompletion of their subpage
+ names in search suggestions. Right now the only useful implementation is in
+ Special:Log, but more are to come.
=== Bug fixes in 1.24 ===
* (bug 49116) Footer copyright notice is now always displayed in user language
protected function specialSearch( $search, $limit ) {
global $wgContLang;
- # normalize searchKey, so aliases with spaces can be found - bug 25675
- $search = str_replace( ' ', '_', $search );
+ list( $searchKey, $subpageSearch ) = explode( '/', $search, 2 );
+
+ // Handle subpage search separately.
+ if ( $subpageSearch !== null ) {
+ // Try matching the full search string as a page name
+ $specialTitle = Title::makeTitleSafe( NS_SPECIAL, $searchKey );
+ $special = SpecialPageFactory::getPage( $specialTitle->getText() );
+ if ( $special ) {
+ $subpages = $special->prefixSearchSubpages( $subpageSearch, $limit );
+ return array_map( function ( $sub ) use ( $specialTitle ) {
+ return $specialTitle->getSubpage( $sub );
+ }, $subpages );
+ } else {
+ return array();
+ }
+ }
- $searchKey = $wgContLang->caseFold( $search );
+ # normalize searchKey, so aliases with spaces can be found - bug 25675
+ $searchKey = str_replace( ' ', '_', $searchKey );
+ $searchKey = $wgContLang->caseFold( $searchKey );
// Unlike SpecialPage itself, we want the canonical forms of both
// canonical and alias title forms...
}
}
+ /**
+ * Return an array of subpages beginning with $search that this special page will accept.
+ *
+ * For example, if a page supports subpages "foo", "bar" and "baz" (as in Special:PageName/foo,
+ * etc.):
+ *
+ * - `prefixSearchSubpages( "ba" )` should return `array( "bar", "baz" )`
+ * - `prefixSearchSubpages( "f" )` should return `array( "foo" )`
+ * - `prefixSearchSubpages( "z" )` should return `array()`
+ * - `prefixSearchSubpages( "" )` should return `array( foo", "bar", "baz" )`
+ *
+ * @param string $search Prefix to search for
+ * @param integer $limit Maximum number of results to return
+ * @return string[] Matching subpages
+ */
+ public function prefixSearchSubpages( $search, $limit = 10 ) {
+ return array();
+ }
+
/**
* Sets headers - this should be called from the execute() method of all derived classes!
*/
$this->show( $opts, $qc );
}
+ /**
+ * Return an array of subpages beginning with $search that this special page will accept.
+ *
+ * @param string $search Prefix to search for
+ * @param integer $limit Maximum number of results to return
+ * @return string[] Matching subpages
+ */
+ public function prefixSearchSubpages( $search, $limit = 10 ) {
+ global $wgLogTypes;
+ $subpages = $wgLogTypes;
+ $subpages[] = 'all';
+ sort( $subpages );
+ $escaped = preg_quote( $search );
+ return array_slice( preg_grep( "/^$escaped/i", $subpages ), 0, $limit );
+ }
+
private function parseParams( FormOptions $opts, $par ) {
global $wgLogTypes;
parent::execute( $subpage );
}
+ /**
+ * Return an array of subpages beginning with $search that this special page will accept.
+ *
+ * @param string $search Prefix to search for
+ * @param integer $limit Maximum number of results to return
+ * @return string[] Matching subpages
+ */
+ public function prefixSearchSubpages( $search, $limit = 10 ) {
+ $subpages = array( 'edit', 'raw' );
+ $escaped = preg_quote( $search );
+ return array_slice( preg_grep( "/^$escaped/i", $subpages ), 0, $limit );
+ }
+
/**
* Get a FormOptions object containing the default options
*