r109626 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109625‎ | r109626 | r109627 >
Date:16:12, 20 January 2012
Author:ialex
Status:ok
Tags:core 
Comment:
* Inlinise Preferences::loadOldSearchNs() in SearchEngine::userNamespaces(); the latter is the only caller of the former
* Made code clearer and removed duplication
* Marked Preferences::loadOldSearchNs() as deprecated
Modified paths:
  • /trunk/phase3/includes/Preferences.php (modified) (history)
  • /trunk/phase3/includes/search/SearchEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/search/SearchEngine.php
@@ -344,21 +344,23 @@
345345 public static function userNamespaces( $user ) {
346346 global $wgSearchEverythingOnlyLoggedIn;
347347
 348+ $searchableNamespaces = SearchEngine::searchableNamespaces();
 349+
348350 // get search everything preference, that can be set to be read for logged-in users
349 - $searcheverything = false;
350 - if ( ( $wgSearchEverythingOnlyLoggedIn && $user->isLoggedIn() )
351 - || !$wgSearchEverythingOnlyLoggedIn )
352 - $searcheverything = $user->getOption( 'searcheverything' );
 351+ // it overrides other options
 352+ if ( !$wgSearchEverythingOnlyLoggedIn || $user->isLoggedIn() ) {
 353+ if ( $user->getOption( 'searcheverything' ) ) {
 354+ return array_keys( $searchableNamespaces );
 355+ }
 356+ }
353357
354 - // searcheverything overrides other options
355 - if ( $searcheverything )
356 - return array_keys( SearchEngine::searchableNamespaces() );
 358+ $arr = array();
 359+ foreach ( $searchableNamespaces as $ns => $name ) {
 360+ if ( $user->getOption( 'searchNs' . $ns ) ) {
 361+ $arr[] = $ns;
 362+ }
 363+ }
357364
358 - $arr = Preferences::loadOldSearchNs( $user );
359 - $searchableNamespaces = SearchEngine::searchableNamespaces();
360 -
361 - $arr = array_intersect( $arr, array_keys( $searchableNamespaces ) ); // Filter
362 -
363365 return $arr;
364366 }
365367
Index: trunk/phase3/includes/Preferences.php
@@ -1456,10 +1456,13 @@
14571457 }
14581458
14591459 /**
 1460+ * @deprecated in 1.19; will be removed in 1.20.
14601461 * @param $user User
14611462 * @return array
14621463 */
14631464 public static function loadOldSearchNs( $user ) {
 1465+ wfDeprecated( __METHOD__, '1.19' );
 1466+
14641467 $searchableNamespaces = SearchEngine::searchableNamespaces();
14651468 // Back compat with old format
14661469 $arr = array();

Sign-offs

UserFlagDate
😂inspected18:22, 26 January 2012

Status & tagging log