Addshore has uploaded a new change for review.

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

Change subject: Re add JSON entity keys
......................................................................

Re add JSON entity keys

This broke due to:
https://gerrit.wikimedia.org/r/#/c/227686

This is a similar sort of thing that we ran
into with sitelinks and terms.

I'll add a genentities integration test
in a followup

Change-Id: I16cff8a7392a67a2292cb9e53cbd97ad53b16632
---
M repo/includes/api/ResultBuilder.php
M repo/tests/phpunit/includes/api/ResultBuilderTest.php
2 files changed, 35 insertions(+), 4 deletions(-)


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

diff --git a/repo/includes/api/ResultBuilder.php 
b/repo/includes/api/ResultBuilder.php
index 707aa8b..9b82c58 100644
--- a/repo/includes/api/ResultBuilder.php
+++ b/repo/includes/api/ResultBuilder.php
@@ -310,7 +310,13 @@
 
                $this->appendValue( array( 'entities' ), 
$sourceEntityIdSerialization, $record, 'entity' );
                if ( $this->addMetaData ) {
-                       $this->result->addArrayType( array( 'entities' ), 
'array' );
+                       $this->result->addArrayType( array( 'entities' ), 
'kvp', 'id' );
+                       $this->result->addValue(
+                               array( 'entities' ),
+                               ApiResult::META_KVP_MERGE,
+                               true,
+                               ApiResult::OVERRIDE
+                       );
                }
        }
 
@@ -1028,6 +1034,13 @@
 
                if ( $this->addMetaData ) {
                        $this->result->addIndexedTagName( 'entities', 'entity' 
);
+                       $this->result->addArrayType( array( 'entities' ), 
'kvp', 'id' );
+                       $this->result->addValue(
+                               array( 'entities' ),
+                               ApiResult::META_KVP_MERGE,
+                               true,
+                               ApiResult::OVERRIDE
+                       );
                }
 
                $this->missingEntityCounter--;
diff --git a/repo/tests/phpunit/includes/api/ResultBuilderTest.php 
b/repo/tests/phpunit/includes/api/ResultBuilderTest.php
index a69c3fa..035166a 100644
--- a/repo/tests/phpunit/includes/api/ResultBuilderTest.php
+++ b/repo/tests/phpunit/includes/api/ResultBuilderTest.php
@@ -329,7 +329,9 @@
                                        ),
                                ),
                                '_element' => 'entity',
-                               '_type' => 'array',
+                               '_type' => 'kvp',
+                               '_kvpkeyname' => 'id',
+                               '_kvpmerge' => true,
                        ),
                        '_type' => 'assoc',
                );
@@ -462,7 +464,9 @@
                                        ),
                                ),
                                '_element' => 'entity',
-                               '_type' => 'array',
+                               '_type' => 'kvp',
+                               '_kvpkeyname' => 'id',
+                               '_kvpmerge' => true,
                        ),
                        '_type' => 'assoc',
                );
@@ -645,7 +649,9 @@
                                        ),
                                ),
                                '_element' => 'entity',
-                               '_type' => 'array',
+                               '_type' => 'kvp',
+                               '_kvpkeyname' => 'id',
+                               '_kvpmerge' => true,
                        ),
                        '_type' => 'assoc',
                );
@@ -1286,6 +1292,9 @@
                                                        'missing' => '',
                                                ),
                                                '_element' => 'entity',
+                                               '_type' => 'kvp',
+                                               '_kvpkeyname' => 'id',
+                                               '_kvpmerge' => true,
                                        ),
                                        '_type' => 'assoc',
                                )
@@ -1301,6 +1310,9 @@
                                                        'missing' => '',
                                                ),
                                                '_element' => 'entity',
+                                               '_type' => 'kvp',
+                                               '_kvpkeyname' => 'id',
+                                               '_kvpmerge' => true,
                                        ),
                                        '_type' => 'assoc',
                                )
@@ -1316,6 +1328,9 @@
                                                        'missing' => '',
                                                ),
                                                '_element' => 'entity',
+                                               '_type' => 'kvp',
+                                               '_kvpkeyname' => 'id',
+                                               '_kvpmerge' => true,
                                        ),
                                        '_type' => 'assoc',
                                )
@@ -1338,6 +1353,9 @@
                                                        'missing' => '',
                                                ),
                                                '_element' => 'entity',
+                                               '_type' => 'kvp',
+                                               '_kvpkeyname' => 'id',
+                                               '_kvpmerge' => true,
                                        ),
                                        '_type' => 'assoc',
                                )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I16cff8a7392a67a2292cb9e53cbd97ad53b16632
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: wmf/1.26wmf22
Gerrit-Owner: Addshore <[email protected]>

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

Reply via email to