Addshore has uploaded a new change for review.

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

Change subject: APIPOKE - Return for-language key for non raw fallbacks
......................................................................

APIPOKE - Return for-language key for non raw fallbacks

Previous to this change the for-language key is only
returned in rawmode (XML), and only when it differs
from the 'language' key.

The needs for rawmode has now been removed
meaning that this key can be returned in formats
such as JSON.

This now provides consumers with a tiny bit of
duplicate infomation as the lagnuage is also availible
as the key in formats such as JSON.

This is a step towards having the same format for
XML and JSON.

This shouldn't break anything as we are only adding
extra info, not removing anything....

Bug: T95168
Change-Id: Ibe1e84b6197fcf54556605919a912d05441ca70d
---
M repo/includes/api/ResultBuilder.php
M repo/tests/phpunit/includes/api/ResultBuilderTest.php
2 files changed, 6 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/67/227667/1

diff --git a/repo/includes/api/ResultBuilder.php 
b/repo/includes/api/ResultBuilder.php
index 7369a91..45202e7 100644
--- a/repo/includes/api/ResultBuilder.php
+++ b/repo/includes/api/ResultBuilder.php
@@ -466,7 +466,7 @@
                                                
$fallbackSerialization['source-language'] = $fallbackSerialization['source'];
                                        }
                                        unset( $fallbackSerialization['source'] 
);
-                                       if ( $this->isRawMode && 
$requestedLanguageCode !== $fallbackSerialization['language'] ) {
+                                       if ( $requestedLanguageCode !== 
$fallbackSerialization['language'] ) {
                                                
$fallbackSerialization['for-language'] = $requestedLanguageCode;
                                        }
                                        
$newSerialization[$requestedLanguageCode] = $fallbackSerialization;
diff --git a/repo/tests/phpunit/includes/api/ResultBuilderTest.php 
b/repo/tests/phpunit/includes/api/ResultBuilderTest.php
index 9083ca8..549fc83 100644
--- a/repo/tests/phpunit/includes/api/ResultBuilderTest.php
+++ b/repo/tests/phpunit/includes/api/ResultBuilderTest.php
@@ -499,18 +499,22 @@
                                                                'de-formal' => 
array(
                                                                        
'language' => 'de',
                                                                        'value' 
=> 'Oslo-de',
+                                                                       
'for-language' => 'de-formal',
                                                                ),
                                                                'es' => array(
                                                                        
'language' => 'en',
                                                                        'value' 
=> 'Oslo-en',
+                                                                       
'for-language' => 'es',
                                                                ),
                                                                'qug' => array(
                                                                        
'language' => 'en',
                                                                        'value' 
=> 'Oslo-en',
+                                                                       
'for-language' => 'qug',
                                                                ),
                                                                'zh-my' => 
array(
                                                                        
'language' => 'en',
                                                                        'value' 
=> 'Oslo-en',
+                                                                       
'for-language' => 'zh-my',
                                                                ),
                                                        ),
                                                        'descriptions' => array(
@@ -521,6 +525,7 @@
                                                                'qug' => array(
                                                                        
'language' => 'es',
                                                                        'value' 
=> 'desc-es',
+                                                                       
'for-language' => 'qug',
                                                                ),
                                                                'zh-my' => 
array(
                                                                        
'language' => 'zh-my',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe1e84b6197fcf54556605919a912d05441ca70d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>

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

Reply via email to