Aude has uploaded a new change for review.

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

Change subject: Introduce $wgMFSearchUseDisplayTitle
......................................................................

Introduce $wgMFSearchUseDisplayTitle

For multilingual wikis like Wikidata, display title is
undesirable since it is set in one language only.

(e.g. on Wikidata, people viewing Special:Nearby in may see
the display title (e.g. "No label defined (Q4497296)")
even if their language is set to something other than English.)

In I736a8e3, we tried setting Wikidata's setting to something
different that omits requesting pageprops. However, for
array-based settings, extension registration applies array_merge
to combine what is set in LocalSettings.php with the default.
This works for adding to the default or replacing part of the
default array, but not to unset part of the default array.

Extension registration supports something called attributes
(used in VisualEditor to register additional modules), but
that does array_merge_recursive and I don't think would work
for this.

With this change, use of display title in search is separated
out into another setting and prop module pageprops and
ppprop => displaytitle are added if the setting is set to
true. (the default)

Bug: T120197
Change-Id: I4f71d116b74866027252be5a380b6d9df59b03bf
---
M extension.json
M includes/MobileFrontend.hooks.php
2 files changed, 17 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/58/269258/3

diff --git a/extension.json b/extension.json
index 7315c12..734fbe5 100644
--- a/extension.json
+++ b/extension.json
@@ -1988,12 +1988,9 @@
                "MFNearbyRange": 10000,
                "MFNearby": false,
                "MFNearbyEndpoint": "",
-               "MFSearchAPIParams": {
-                       "ppprop": "displaytitle"
-               },
-               "MFQueryPropModules": [
-                       "pageprops"
-               ],
+               "MFSearchUseDisplayTitle": true,
+               "MFSearchAPIParams": [],
+               "MFQueryPropModules": [],
                "MFSearchGenerator": {
                        "name": "prefixsearch",
                        "prefix": "ps"
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index 812fd21..18dedb8 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -360,11 +360,20 @@
                $context = MobileContext::singleton();
                $config = $context->getMFConfig();
 
-               $pageProps = $config->get( 'MFQueryPropModules' );
+               $propModules = $config->get( 'MFQueryPropModules' );
                $searchParams = $config->get( 'MFSearchAPIParams' );
+
+               if ( $config->get( 'MFSearchUseDisplayTitle' ) === true ) {
+                       if ( !in_array( 'pageprops', $propModules ) ) {
+                               $propModules[] = 'pageprops';
+                       }
+
+                       $searchParams['ppprop'][] = 'displaytitle';
+               }
+
                // Avoid API warnings and allow integration with optional 
extensions.
                if ( defined( 'PAGE_IMAGES_INSTALLED' ) ) {
-                       $pageProps[] = 'pageimages';
+                       $propModules[] = 'pageimages';
                        $searchParams = array_merge_recursive( $searchParams, 
array(
                                'piprop' => 'thumbnail',
                                'pithumbsize' => MobilePage::SMALL_IMAGE_WIDTH,
@@ -385,8 +394,8 @@
                // When set turn on Wikidata descriptions
                // https://phabricator.wikimedia.org/T101719
                if ( $useDescriptions && $displayDescriptions ) {
-                       if ( !in_array( 'pageterms', $pageProps ) ) {
-                               $pageProps[] = 'pageterms';
+                       if ( !in_array( 'pageterms', $propModules ) ) {
+                               $propModules[] = 'pageterms';
                        }
                        $searchParams = array_merge_recursive( $searchParams, 
array(
                                'wbptterms' => 'description',
@@ -397,7 +406,7 @@
                $wgMFUploadLicense = MobileFrontendSkinHooks::getLicense( 
'upload' );
                $vars += array(
                        'wgMFSearchAPIParams' => $searchParams,
-                       'wgMFQueryPropModules' => $pageProps,
+                       'wgMFQueryPropModules' => $propModules,
                        'wgMFSearchGenerator' => $config->get( 
'MFSearchGenerator' ),
                        'wgMFNearbyEndpoint' => $config->get( 
'MFNearbyEndpoint' ),
                        'wgMFThumbnailSizes' => array(

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f71d116b74866027252be5a380b6d9df59b03bf
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to