r40549 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40548‎ | r40549 | r40550 >
Date:21:18, 6 September 2008
Author:nad
Status:old
Tags:
Comment:
Add hack to ensure searchEngine type is based on initial DB type
Modified paths:
  • /trunk/extensions/SimpleSecurity/SimpleSecurity.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SimpleSecurity/SimpleSecurity.php
@@ -21,7 +21,7 @@
2222 if (!defined('MEDIAWIKI')) die('Not an entry point.');
2323 if (version_compare($wgVersion, '1.11.0') < 0) die('Sorry, this extension requires at least MediaWiki version 1.11.0');
2424
25 -define('SIMPLESECURITY_VERSION', '4.2.12, 2008-09-06');
 25+define('SIMPLESECURITY_VERSION', '4.2.13, 2008-09-07');
2626
2727 # Global security settings
2828 $wgSecurityMagicIf = "ifusercan"; # the name for doing a permission-based conditional
@@ -53,6 +53,9 @@
5454 'version' => SIMPLESECURITY_VERSION
5555 );
5656
 57+# SearchEngine is based on $wgDBtype so must be set before it gets changed to DatabaseSimpleSecurity
 58+SimpleSecurity::fixSearchType();
 59+
5760 # If the database class already exists, add the DB hook now, otherwise wait until extension setup
5861 if (!isset($wgSecurityUseDBHook)) $wgSecurityUseDBHook = false;
5962 if ($wgSecurityUseDBHook && class_exists('Database')) wfSimpleSecurityDBHook();
@@ -374,11 +377,25 @@
375378 }
376379 }
377380
378 - # Updates passed LoadBalancer's DB servers to secure class
 381+ /**
 382+ * Updates passed LoadBalancer's DB servers to secure class
 383+ */
379384 static function updateLB(&$lb) {
380385 $lb->closeAll();
381386 foreach ($lb->mServers as $i => $server) $lb->mServers[$i]['type'] = 'SimpleSecurity';
382387 }
 388+
 389+ /**
 390+ * Hack to ensure proper search class is used
 391+ */
 392+ static function fixSearchType() {
 393+ global $wgDBtype, $wgSearchType;
 394+ if ($wgSearchType) return;
 395+ elseif ($wgDBtype == 'mysql') $wgSearchType = 'SearchMySQL4';
 396+ elseif ($wgDBtype == 'postgres') $wgSearchType = 'SearchPostgres';
 397+ elseif ($wgDBtype == 'oracle') $wgSearchType = 'SearchOracle';
 398+ else $wgSearchType = 'SearchEngineDummy';
 399+ }
383400 }
384401
385402 /**
@@ -428,7 +445,7 @@
429446 * Called from $wgExtensionFunctions array when initialising extensions
430447 */
431448 function wfSetupSimpleSecurity() {
432 - global $wgSimpleSecurity, $wgLanguageCode, $wgMessageCache, $wgSecurityUseDBHook, $wgLoadBalancer;
 449+ global $wgSimpleSecurity, $wgLanguageCode, $wgMessageCache, $wgSecurityUseDBHook, $wgLoadBalancer;
433450
434451 # Instantiate the SimpleSecurity singleton now that the environment is prepared
435452 $wgSimpleSecurity = new SimpleSecurity();

Status & tagging log