r36482 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36481‎ | r36482 | r36483 >
Date:21:19, 19 June 2008
Author:brion
Status:old
Tags:
Comment:
Security fix: don't let register_globals set our defaults for us!
* Define all our globals
* Change doc comment to correct recommendations for config order
* Set our conditional hook in an extension setup function, so it's after we got our config set
* Removed unnecessary invocation guard
Modified paths:
  • /trunk/extensions/MWSearch/MWSearch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MWSearch/MWSearch.php
@@ -24,13 +24,13 @@
2525 */
2626
2727 # To use this, add something like the following to LocalSettings:
 28+#
 29+# require_once("extensions/MWSearch/MWSearch.php");
2830 #
2931 # $wgSearchType = 'LuceneSearch';
3032 # $wgLuceneHost = '192.168.0.1';
3133 # $wgLucenePort = 8123;
3234 #
33 -# require_once("extensions/MWSearch/MWSearch.php");
34 -#
3535 # To load-balance with from multiple servers:
3636 #
3737 # $wgLuceneHost = array( "192.168.0.1", "192.168.0.2" );
@@ -41,26 +41,19 @@
4242
4343
4444 # Back-end version (override before including MWSearch.php)
45 -if( !isset($wgLuceneSearchVersion) )
46 - $wgLuceneSearchVersion = 2;
 45+$wgLuceneSearchVersion = 2;
4746
4847 # If to show related links (if available) below search results
49 -if( !isset($wgLuceneUseRelated) )
50 - $wgLuceneUseRelated = false;
 48+$wgLuceneUseRelated = false;
5149
5250 # If to use lucene as a prefix search backend
53 -if( !isset($wgEnableLucenePrefixSearch) )
54 - $wgEnableLucenePrefixSearch = false;
 51+$wgEnableLucenePrefixSearch = false;
5552
5653 # For how long (in seconds) to cache lucene results, off by default (0)
5754 # NOTE: caching is typically inefficient for queries, with cache
5855 # hit rates way below 1% even for very long expiry times
59 -if( !isset($wgLuceneSearchCacheExpiry) )
60 - $wgLuceneSearchCacheExpiry = 0;
 56+$wgLuceneSearchCacheExpiry = 0;
6157
62 -# Not a valid entry point, skip unless MEDIAWIKI is defined
63 -if( defined('MEDIAWIKI') ){
64 -
6558 $wgExtensionCredits['other'][] = array(
6659 'name' => 'MWSearch',
6760 'svn-date' => '$LastChangedDate$',
@@ -73,13 +66,14 @@
7467 $dir = dirname(__FILE__) . '/';
7568
7669 $wgExtensionMessagesFiles['MWSearch'] = $dir . 'MWSearch.i18n.php';
 70+$wgExtensionFunctions[] = 'efLucenePrefixSetup';
7771
78 -if($wgLuceneSearchVersion >= 2.1 && $wgEnableLucenePrefixSearch)
79 - $wgHooks['PrefixSearchBackend'][] = 'LuceneSearch::prefixSearch';
80 -
8172 $wgAutoloadClasses['LuceneSearch'] = $dir . 'MWSearch_body.php';
8273 $wgAutoloadClasses['LuceneResult'] = $dir . 'MWSearch_body.php';
8374 $wgAutoloadClasses['LuceneSearchSet'] = $dir . 'MWSearch_body.php';
8475
85 -} # End of invocation guard
86 -
 76+function efLucenePrefixSetup() {
 77+ global $wgHooks, $wgLuceneSearchVersion, $wgEnableLucenePrefixSearch;
 78+ if($wgLuceneSearchVersion >= 2.1 && $wgEnableLucenePrefixSearch)
 79+ $wgHooks['PrefixSearchBackend'][] = 'LuceneSearch::prefixSearch';
 80+}

Status & tagging log