DCausse has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311675

Change subject: Pass User to SearchEngine::getProfile
......................................................................

Pass User to SearchEngine::getProfile

Useful for search engines that wants to allow users to customize search 
profiles.

Change-Id: I471cd090730d2a25cb70d622ec3bebbe9583118c
---
M includes/api/SearchApi.php
M includes/search/SearchEngine.php
2 files changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/75/311675/1

diff --git a/includes/api/SearchApi.php b/includes/api/SearchApi.php
index 8ae1192..fb9c4e6 100644
--- a/includes/api/SearchApi.php
+++ b/includes/api/SearchApi.php
@@ -104,7 +104,8 @@
                $searchEngine = 
MediaWikiServices::getInstance()->newSearchEngine();
                $params = [];
                foreach ( $configs as $paramName => $paramConfig ) {
-                       $profiles = $searchEngine->getProfiles( 
$paramConfig['profile-type'] );
+                       $profiles = $searchEngine->getProfiles( 
$paramConfig['profile-type'],
+                               $this->getContext()->getUser() );
                        if ( !$profiles ) {
                                continue;
                        }
@@ -188,4 +189,9 @@
         *  containing 'help-message' and 'profile-type' keys.
         */
        abstract public function getSearchProfileParams();
+
+       /**
+        * @return IContextSource
+        */
+       abstract public function getContext();
 }
diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php
index 1eba141..da93a07 100644
--- a/includes/search/SearchEngine.php
+++ b/includes/search/SearchEngine.php
@@ -648,10 +648,11 @@
         * - default: set to true if this profile is the default
         *
         * @since 1.28
-        * @param $profileType the type of profiles
+        * @param string $profileType the type of profiles
+        * @param User|null $user the user requesting the list of profiles
         * @return array|null the list of profiles or null if none available
         */
-       public function getProfiles( $profileType ) {
+       public function getProfiles( $profileType, User $user = null ) {
                return null;
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/311675
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I471cd090730d2a25cb70d622ec3bebbe9583118c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: DCausse <dcau...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to