edit, via the parameter 'bot'. (Default: '1')
* (bug 12536) User should be able to get MediaWiki version from any page
* (bug 12622) A JavaScript constant to declare whether api.php is available
-
+* Add caching to the AJAX search
+
=== Bug fixes in 1.12 ===
return '';
}
+define( 'AJAX_SEARCH_VERSION', 1 ); //AJAX search cache version
+
function wfSajaxSearch( $term ) {
- global $wgContLang, $wgOut, $wgUser, $wgCapitalLinks;
+ global $wgContLang, $wgOut, $wgUser, $wgCapitalLinks, $wgMemc;
$limit = 16;
$sk = $wgUser->getSkin();
$term = $wgContLang->ucfirst( $term );
$term_title = Title::newFromText( $term );
+ $memckey = wfMemcKey( 'ajaxsearch', md5( $term_title->getFullText() ) );
+ $cached = $wgMemc->get($memckey);
+ if( is_array( $cached ) && $cached['version'] == AJAX_SEARCH_VERSION ) {
+ $response = new AjaxResponse( $cached['html'] );
+ $response->setCacheDuration( 30*60 );
+ return $response;
+ }
+
$r = $more = '';
$canSearch = true;
if( $term_title && $term_title->getNamespace() != NS_SPECIAL ) {
. '<ul>' .$r .'</ul>' . $more;
}
- $response = new AjaxResponse( $html );
+ $wgMemc->set( $memckey, array( 'version' => AJAX_SEARCH_VERSION, 'html' => $html ), 30 * 60 );
+ $response = new AjaxResponse( $html );
$response->setCacheDuration( 30*60 );
-
return $response;
}