diff --git a/build/integration/features/bootstrap/Sharing.php b/build/integration/features/bootstrap/Sharing.php
index 29bae9843c2..b83edec7caf 100644
--- a/build/integration/features/bootstrap/Sharing.php
+++ b/build/integration/features/bootstrap/Sharing.php
@@ -729,6 +729,37 @@ trait Sharing {
$shareeType = substr($shareeType, 6);
}
+ // "simplexml_load_string" creates a SimpleXMLElement object for each
+ // XML element with child elements. In turn, each child is indexed by
+ // its tag in the SimpleXMLElement object. However, when there are
+ // several child XML elements with the same tag, an array with all the
+ // children with the same tag is indexed instead. Therefore, when the
+ // XML contains
+ //
+ //
+ //
+ // ...
+ //
+ //
+ // the "$elements[$shareeType]" variable contains an "element" key which
+ // in turn contains "label" and "value" keys, but when the XML contains
+ //
+ //
+ //
+ // ...
+ //
+ //
+ //
+ // ...
+ //
+ //
+ // the "$elements[$shareeType]" variable contains an "element" key which
+ // in turn contains "0" and "1" keys, and in turn each one contains
+ // "label" and "value" keys.
+ if (array_key_exists('element', $elements[$shareeType]) && is_int(array_keys($elements[$shareeType]['element'])[0])) {
+ $elements[$shareeType] = $elements[$shareeType]['element'];
+ }
+
$sharees = [];
foreach ($elements[$shareeType] as $element) {
$sharee = [$element['label'], $element['value']['shareType'], $element['value']['shareWith']];
diff --git a/build/integration/sharees_features/sharees.feature b/build/integration/sharees_features/sharees.feature
index 7b0d8b903dc..29e185e5d63 100644
--- a/build/integration/sharees_features/sharees.feature
+++ b/build/integration/sharees_features/sharees.feature
@@ -8,6 +8,7 @@ Feature: sharees
And user "Sharee1" exists
And group "ShareeGroup" exists
And user "test" belongs to group "ShareeGroup"
+ And user "Sharee2" exists
Scenario: Search without exact match
Given As an "test"
@@ -19,6 +20,7 @@ Feature: sharees
And "exact users" sharees returned is empty
And "users" sharees returned are
| Sharee1 | 0 | Sharee1 | Sharee1 |
+ | Sharee2 | 0 | Sharee2 | Sharee2 |
And "exact groups" sharees returned is empty
And "groups" sharees returned are
| ShareeGroup | 1 | ShareeGroup |
@@ -35,6 +37,7 @@ Feature: sharees
And "exact users" sharees returned is empty
And "users" sharees returned are
| Sharee1 | 0 | Sharee1 | Sharee1 |
+ | Sharee2 | 0 | Sharee2 | Sharee2 |
And "exact groups" sharees returned is empty
And "groups" sharees returned are
| ShareeGroup | 1 | ShareeGroup |
@@ -254,6 +257,7 @@ Feature: sharees
And "exact users" sharees returned is empty
And "users" sharees returned are
| Sharee1 | 0 | Sharee1 | Sharee1 |
+ | Sharee2 | 0 | Sharee2 | Sharee2 |
And "exact groups" sharees returned is empty
And "groups" sharees returned is empty
And "exact remotes" sharees returned is empty