diff --git a/CHANGELOG.md b/CHANGELOG.md index 32bedb6..0e11190 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 3.3.3-beta.2 - 2024-02-13 +### Fixed +- Fixed missing deletion of orphans of split elements ([#259](https://github.com/studioespresso/craft-scout/issues/259)) + ## 3.3.3-beta.1 - 2023-12-06 ### Fixed - This beta release is a first try at resolving an issue with deindexing of element not working properly. ([#281](https://github.com/studioespresso/craft-scout/issues/281)) diff --git a/README.md b/README.md index a14e562..ca0852c 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,9 @@ You can use this to define index settings that get synced when you call the `./c This way you can keep your index settings in source control. The IndexSettings object provides autocompletion for all Algolia's settings +> [!NOTE] +> Note that settings are not synced automatically, but only when the `./craft scout/settings/update` console command is run. + ```php ->indexSettings( \rias\scout\IndexSettings::create() diff --git a/composer.json b/composer.json index ef4c235..0960d8e 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "studioespresso/craft-scout", "description": "Craft Scout provides a simple solution for adding full-text search to your entries. Scout will automatically keep your search indexes in sync with your entries.", "type": "craft-plugin", - "version": "3.3.3-beta.1", + "version": "3.3.3-beta.2", "keywords": [ "craft", "cms", diff --git a/src/engines/Engine.php b/src/engines/Engine.php index 73d8a08..d665372 100644 --- a/src/engines/Engine.php +++ b/src/engines/Engine.php @@ -43,16 +43,13 @@ public function splitObjects(array $objects): array $objectToSave['distinctID'] = $objectToSave['objectID']; $objectsToSave[] = $objectToSave; } - - continue; - } - - foreach ($splittedObjects as $part => $splittedObject) { - $splittedObject['distinctID'] = $splittedObject['objectID']; - $splittedObject['objectID'] = "{$splittedObject['objectID']}_{$part}"; - $objectsToSave[] = $splittedObject; + } else { + foreach ($splittedObjects as $part => $splittedObject) { + $splittedObject['distinctID'] = $splittedObject['objectID']; + $splittedObject['objectID'] = "{$splittedObject['objectID']}_{$part}"; + $objectsToSave[] = $splittedObject; + } } - $objectsToDelete[] = $object; } diff --git a/tests/_craft/config/db.php b/tests/_craft/config/db.php index 4078ec3..d55c36d 100644 --- a/tests/_craft/config/db.php +++ b/tests/_craft/config/db.php @@ -1,12 +1,12 @@ getenv('DB_SERVER') ?? '127.0.0.1', - 'user' => getenv('DB_USER') ?? 'root', - 'password' => getenv('DB_PASSWORD') ?? 'root', - 'database' => getenv('DB_DATABASE') ?? 'scout_testing', + 'server' => '127.0.0.1', + 'user' => 'root', + 'password' => 'root', + 'database' => 'scout_testing', 'schema' => getenv('DB_SCHEMA'), 'tablePrefix' => '', 'driver' => 'mysql', - 'port' => getenv('DB_PORT') ?? 3306, + 'port' => 3306, ]; diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml new file mode 100644 index 0000000..5582476 --- /dev/null +++ b/tests/docker-compose.yml @@ -0,0 +1,14 @@ +version: "2" +services: + mysql: + restart: always + image: mysql/mysql-server:5.7 + environment: + MYSQL_ROOT_PASSWORD: "root_password" + MYSQL_DATABASE: "scout_testing" + MYSQL_USER: "root" + MYSQL_PASSWORD: "root" + MYSQL_ROOT_HOST: "0.0.0.0" + MYSQL_ALLOW_EMPTY_PASSWORD: "yes" + ports: + - "3306:3306" diff --git a/tests/unit/ScoutIndexTest.php b/tests/unit/ScoutIndexTest.php index f69ff26..1290109 100644 --- a/tests/unit/ScoutIndexTest.php +++ b/tests/unit/ScoutIndexTest.php @@ -112,7 +112,7 @@ public function it_throws_an_exception_if_no_query_is_returned_from_criteria() } /** @test * */ - public function it_sets_the_primary_site_id_if_the_criteria_has_no_site_id() + public function it_checks_any_site_if_the_criteria_has_no_site_id() { $index = new ScoutIndex('Blog'); @@ -120,6 +120,6 @@ public function it_sets_the_primary_site_id_if_the_criteria_has_no_site_id() return $query; }); - $this->assertEquals(Craft::$app->getSites()->getPrimarySite()->id, $index->criteria->siteId); + $this->assertEquals('*', $index->criteria->siteId); } }