Skip to content

Commit 785325b

Browse files
srueggdaniellienert
authored andcommitted
BUGFIX: Index by alias, treated content (#203)
* BUGFIX: Do not throw an error if index is not found * BUGFIX Return an empty array if treatedContent is not an array
1 parent 99ba809 commit 785325b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Classes/Driver/Version1/IndexDriver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ public function deleteIndex($index)
5252
public function indexesByAlias($alias)
5353
{
5454
$response = $this->searchClient->request('GET', '/_alias/' . $alias);
55-
if ($response->getStatusCode() !== 200) {
55+
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 404) {
5656
throw new Exception('The alias "' . $alias . '" was not found with some unexpected error... (return code: ' . $response->getStatusCode() . ')', 1383650137);
5757
}
5858

59-
return array_keys($response->getTreatedContent());
59+
// return empty array if content from response cannot be read as an array
60+
$treatedContent = $response->getTreatedContent();
61+
return is_array($treatedContent) ? array_keys($treatedContent) : [];
6062
}
6163
}

0 commit comments

Comments
 (0)