Skip to content

Commit f9b4ad9

Browse files
committed
changed: updated for Elgg 6.2
1 parent 7fdaacb commit f9b4ad9

File tree

15 files changed

+771
-72
lines changed

15 files changed

+771
-72
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OpenSearch
22

3-
![Elgg 6.1](https://img.shields.io/badge/Elgg-6.1-green.svg)
3+
![Elgg 6.2](https://img.shields.io/badge/Elgg-6.2-green.svg)
44
![OpenSearch 2.5](https://img.shields.io/badge/OpenSearch-2.5-green.svg)
55
![Lint Checks](https://github.com/ColdTrick/opensearch/actions/workflows/lint.yml/badge.svg?event=push)
66
[![Latest Stable Version](https://poser.pugx.org/coldtrick/opensearch/v/stable.svg)](https://packagist.org/packages/coldtrick/opensearch)

classes/ColdTrick/OpenSearch/Cron.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use ColdTrick\OpenSearch\Di\IndexingService;
66
use ColdTrick\OpenSearch\Di\SearchService;
77
use Elgg\Database\QueryBuilder;
8-
use OpenSearch\Common\Exceptions\OpenSearchException;
8+
use OpenSearch\Exception\OpenSearchExceptionInterface;
99
use Psr\Log\LogLevel;
1010

1111
/**
@@ -117,7 +117,7 @@ protected static function cleanupOpenSearch(): void {
117117

118118
try {
119119
$scroll_setup = $service->rawSearch($search_params);
120-
} catch (OpenSearchException $e) {
120+
} catch (OpenSearchExceptionInterface $e) {
121121
return;
122122
}
123123

@@ -188,15 +188,15 @@ function (QueryBuilder $qb, $main_alias) {
188188
}
189189
}
190190
});
191-
} catch (OpenSearchException $e) {
191+
} catch (OpenSearchExceptionInterface $e) {
192192
// probably reached the end of the scroll
193193
// elgg_log('OpenSearch cleanup: ' . $e->getMessage(), LogLevel::ERROR);
194194
}
195195

196196
// clear scroll
197197
try {
198198
$service->clearScroll($scroll_params);
199-
} catch (OpenSearchException $e) {
199+
} catch (OpenSearchExceptionInterface $e) {
200200
// unable to clean, could be because we came to the end of the scroll
201201
}
202202
}
@@ -320,7 +320,7 @@ protected static function findUnindexedGUIDs(array $guids = []): array {
320320
$opensearch_guids = $search_result->toGuids();
321321

322322
return array_diff($guids, $opensearch_guids);
323-
} catch (OpenSearchException $e) {
323+
} catch (OpenSearchExceptionInterface $e) {
324324
// some error occurred
325325
}
326326

classes/ColdTrick/OpenSearch/Di/BaseClientService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use Elgg\Traits\Di\ServiceFacade;
88
use OpenSearch\Client;
99
use OpenSearch\ClientBuilder;
10-
use OpenSearch\Common\Exceptions\OpenSearchException;
11-
use OpenSearch\Common\Exceptions\RuntimeException;
10+
use OpenSearch\Exception\OpenSearchExceptionInterface;
11+
use OpenSearch\Exception\RuntimeException;
1212

1313
/**
1414
* Base client for OpenSearch
@@ -62,7 +62,7 @@ public function ping(): bool {
6262

6363
try {
6464
return $this->getClient()->ping();
65-
} catch (OpenSearchException $e) {
65+
} catch (OpenSearchExceptionInterface $e) {
6666
// no need to log
6767
$this->logger->notice($e);
6868
}

classes/ColdTrick/OpenSearch/Di/IndexManagementService.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace ColdTrick\OpenSearch\Di;
44

55
use Elgg\Exceptions\UnexpectedValueException;
6-
use OpenSearch\Common\Exceptions\OpenSearchException;
6+
use OpenSearch\Exception\OpenSearchExceptionInterface;
77

88
/**
99
* Manage the OpenSearch Indexes
@@ -31,7 +31,7 @@ public function getIndexStatus(): ?array {
3131
$status = $this->getClient()->indices()->stats();
3232

3333
return elgg_extract('indices', $status, false);
34-
} catch (OpenSearchException $e) {
34+
} catch (OpenSearchExceptionInterface $e) {
3535
$this->logger->error($e);
3636
}
3737

@@ -50,7 +50,7 @@ public function getClusterInformation(): ?array {
5050

5151
try {
5252
return $this->getClient()->info();
53-
} catch (OpenSearchException $e) {
53+
} catch (OpenSearchExceptionInterface $e) {
5454
$this->logger->error($e);
5555
}
5656

@@ -97,7 +97,7 @@ public function indexExists(string $index): bool {
9797
return $this->getClient()->indices()->exists([
9898
'index' => $index,
9999
]);
100-
} catch (OpenSearchException $e) {
100+
} catch (OpenSearchExceptionInterface $e) {
101101
$this->logger->error($e);
102102
}
103103

@@ -122,7 +122,7 @@ public function indexHasAlias(string $index, string $alias): bool {
122122
'index' => $index,
123123
'name' => $alias,
124124
]);
125-
} catch (OpenSearchException $e) {
125+
} catch (OpenSearchExceptionInterface $e) {
126126
$this->logger->error($e);
127127
}
128128

@@ -148,7 +148,7 @@ public function addAlias(string $index, string $alias): bool {
148148
'name' => $alias,
149149
]);
150150
return (bool) elgg_extract('acknowledged', $response, false);
151-
} catch (OpenSearchException $e) {
151+
} catch (OpenSearchExceptionInterface $e) {
152152
$this->logger->error($e);
153153
}
154154

@@ -174,7 +174,7 @@ public function getAliases(string $index): ?array {
174174

175175
$aliases = elgg_extract('aliases', elgg_extract($index, $response, []), []);
176176
return array_keys($aliases);
177-
} catch (OpenSearchException $e) {
177+
} catch (OpenSearchExceptionInterface $e) {
178178
$this->logger->error($e);
179179
}
180180

@@ -200,7 +200,7 @@ public function deleteAlias(string $index, string $alias): bool {
200200
'name' => $alias,
201201
]);
202202
return (bool) elgg_extract('acknowledged', $response, false);
203-
} catch (OpenSearchException $e) {
203+
} catch (OpenSearchExceptionInterface $e) {
204204
$this->logger->error($e);
205205
}
206206

@@ -226,7 +226,7 @@ public function flush(string $index): bool {
226226

227227
$failed_shards = elgg_extract('failed', elgg_extract('_shards', $response, []), 0);
228228
return empty($failed_shards);
229-
} catch (OpenSearchException $e) {
229+
} catch (OpenSearchExceptionInterface $e) {
230230
$this->logger->error($e);
231231
}
232232

@@ -250,7 +250,7 @@ public function delete(string $index): bool {
250250
'index' => $index,
251251
]);
252252
return (bool) elgg_extract('acknowledged', $response, false);
253-
} catch (OpenSearchException $e) {
253+
} catch (OpenSearchExceptionInterface $e) {
254254
$this->logger->error($e);
255255
}
256256

@@ -274,7 +274,7 @@ public function create(string $index): bool {
274274
try {
275275
$response = $this->getClient()->indices()->create($config);
276276
return (bool) elgg_extract('acknowledged', $response, false);
277-
} catch (OpenSearchException $e) {
277+
} catch (OpenSearchExceptionInterface $e) {
278278
$this->logger->error($e);
279279
}
280280

@@ -298,7 +298,7 @@ public function addMapping(string $index): bool {
298298
try {
299299
$response = $this->getClient()->indices()->putMapping($config);
300300
return (bool) elgg_extract('acknowledged', $response, false);
301-
} catch (OpenSearchException $e) {
301+
} catch (OpenSearchExceptionInterface $e) {
302302
$this->logger->error($e);
303303
}
304304

@@ -330,7 +330,7 @@ public function reindex(string $from_index, string $to_index): ?array {
330330
],
331331
'wait_for_completion' => true,
332332
]);
333-
} catch (OpenSearchException $e) {
333+
} catch (OpenSearchExceptionInterface $e) {
334334
$this->logger->error($e);
335335
}
336336

classes/ColdTrick/OpenSearch/Di/IndexingService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Elgg\Database\QueryBuilder;
66
use Elgg\Cli\Progress;
7-
use OpenSearch\Common\Exceptions\OpenSearchException;
7+
use OpenSearch\Exception\OpenSearchExceptionInterface;
88
use Psr\Log\LogLevel;
99
use Symfony\Component\Console\Helper\ProgressBar;
1010

@@ -79,7 +79,7 @@ public function addEntitiesToIndex(array $entities = []): ?array {
7979

8080
try {
8181
return $this->getClient()->bulk($params);
82-
} catch (OpenSearchException $e) {
82+
} catch (OpenSearchExceptionInterface $e) {
8383
$this->logger->error($e);
8484
}
8585

@@ -129,7 +129,7 @@ public function bulkDeleteDocuments(): bool {
129129
opensearch_add_document_for_deletion($guid, $documents[$guid], '+1 hour');
130130
}
131131
}
132-
} catch (OpenSearchException $e) {
132+
} catch (OpenSearchExceptionInterface $e) {
133133
$this->logger->error($e);
134134
return false;
135135
}

classes/ColdTrick/OpenSearch/Di/SearchService.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use ColdTrick\OpenSearch\SearchParams;
66
use ColdTrick\OpenSearch\SearchResult;
7-
use OpenSearch\Common\Exceptions\OpenSearchException;
7+
use OpenSearch\Exception\OpenSearchExceptionInterface;
88

99
/**
1010
* Perform searches in the OpenSearch index
@@ -48,7 +48,7 @@ public function inspect(int $guid, bool $return_raw = false): ?array {
4848
}
4949

5050
return elgg_extract('_source', $result);
51-
} catch (OpenSearchException $e) {
51+
} catch (OpenSearchExceptionInterface $e) {
5252
$this->logger->error($e);
5353
}
5454

@@ -69,7 +69,7 @@ public function rawSearch(array $params = []): ?array {
6969

7070
try {
7171
return $this->getClient()->search($params);
72-
} catch (OpenSearchException $e) {
72+
} catch (OpenSearchExceptionInterface $e) {
7373
$this->logger->error($e);
7474
}
7575

@@ -113,7 +113,7 @@ public function search(array $body = []): ?SearchResult {
113113
$result = [];
114114
try {
115115
$result = $this->getClient()->search($body);
116-
} catch (OpenSearchException $e) {
116+
} catch (OpenSearchExceptionInterface $e) {
117117
// exception already logged by OpenSearch
118118
}
119119

@@ -162,7 +162,7 @@ public function suggest(string $query): ?SearchResult {
162162
$result = [];
163163
try {
164164
$result = $this->getClient()->search($body);
165-
} catch (OpenSearchException $e) {
165+
} catch (OpenSearchExceptionInterface $e) {
166166
// exception already logged by OpenSearch
167167
}
168168

@@ -204,7 +204,7 @@ public function count(array $body = []): ?SearchResult {
204204
$result = [];
205205
try {
206206
$result = $this->getClient()->count($body);
207-
} catch (OpenSearchException $e) {
207+
} catch (OpenSearchExceptionInterface $e) {
208208
// exception already logged by OpenSearch
209209
}
210210

composer.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,22 @@
1010
"issues": "https://github.com/ColdTrick/opensearch/issues"
1111
},
1212
"require": {
13-
"opensearch-project/opensearch-php": "~2.3.0"
13+
"opensearch-project/opensearch-php": "~2.4.0"
14+
},
15+
"require-dev": {
16+
"guzzlehttp/guzzle": "~7.9.0"
1417
},
1518
"conflict": {
1619
"elgg/elgg": "<6.1"
20+
},
21+
"config": {
22+
"allow-plugins": {
23+
"php-http/discovery": true
24+
}
25+
},
26+
"extra": {
27+
"discovery": {
28+
"psr/http-factory-implementation": "GuzzleHttp\\\\Psr7\\\\HttpFactory"
29+
}
1730
}
1831
}

0 commit comments

Comments
 (0)