https://www.mediawiki.org/wiki/Special:Code/MediaWiki/109626
Revision: 109626
Author: ialex
Date: 2012-01-20 16:12:34 +0000 (Fri, 20 Jan 2012)
Log Message:
-----------
* 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
trunk/phase3/includes/search/SearchEngine.php
Modified: trunk/phase3/includes/Preferences.php
===================================================================
--- trunk/phase3/includes/Preferences.php 2012-01-20 16:12:11 UTC (rev
109625)
+++ trunk/phase3/includes/Preferences.php 2012-01-20 16:12:34 UTC (rev
109626)
@@ -1456,10 +1456,13 @@
}
/**
+ * @deprecated in 1.19; will be removed in 1.20.
* @param $user User
* @return array
*/
public static function loadOldSearchNs( $user ) {
+ wfDeprecated( __METHOD__, '1.19' );
+
$searchableNamespaces = SearchEngine::searchableNamespaces();
// Back compat with old format
$arr = array();
Modified: trunk/phase3/includes/search/SearchEngine.php
===================================================================
--- trunk/phase3/includes/search/SearchEngine.php 2012-01-20 16:12:11 UTC
(rev 109625)
+++ trunk/phase3/includes/search/SearchEngine.php 2012-01-20 16:12:34 UTC
(rev 109626)
@@ -344,21 +344,23 @@
public static function userNamespaces( $user ) {
global $wgSearchEverythingOnlyLoggedIn;
+ $searchableNamespaces = SearchEngine::searchableNamespaces();
+
// get search everything preference, that can be set to be read
for logged-in users
- $searcheverything = false;
- if ( ( $wgSearchEverythingOnlyLoggedIn && $user->isLoggedIn() )
- || !$wgSearchEverythingOnlyLoggedIn )
- $searcheverything = $user->getOption(
'searcheverything' );
+ // it overrides other options
+ if ( !$wgSearchEverythingOnlyLoggedIn || $user->isLoggedIn() ) {
+ if ( $user->getOption( 'searcheverything' ) ) {
+ return array_keys( $searchableNamespaces );
+ }
+ }
- // searcheverything overrides other options
- if ( $searcheverything )
- return array_keys( SearchEngine::searchableNamespaces()
);
+ $arr = array();
+ foreach ( $searchableNamespaces as $ns => $name ) {
+ if ( $user->getOption( 'searchNs' . $ns ) ) {
+ $arr[] = $ns;
+ }
+ }
- $arr = Preferences::loadOldSearchNs( $user );
- $searchableNamespaces = SearchEngine::searchableNamespaces();
-
- $arr = array_intersect( $arr, array_keys( $searchableNamespaces
) ); // Filter
-
return $arr;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs