Skip to content

Commit

Permalink
Merge branch 'release/3.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenckens committed Nov 15, 2023
2 parents dc66bd7 + c3b3520 commit 2140158
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 31 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
DB_PASSWORD: root
DB_PORT: 3306
DB_DRIVER: mysql
DB_SERVER: 127.0.0.1
APP_ENV: testing

steps:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## 3.3.2 - 2023-11-15
### Fixed
- Fixed an error on the Control Panel Utility page ([#284](https://github.com/studioespresso/craft-scout/issues/284))
- Fixed an error when saving elements without a site property ([#285](https://github.com/studioespresso/craft-scout/issues/285****))

## 3.3.1 - 2023-11-08

### Added
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.1",
"version": "3.3.2",
"keywords": [
"craft",
"cms",
Expand Down
4 changes: 2 additions & 2 deletions src/Scout.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function (ElementEvent $event) {
->push(
new IndexElement([
'id' => $element->id,
'siteId' => $element->site->id
'siteId' => $element->site ? $element->site->id : null
])
);
} else {
Expand Down Expand Up @@ -203,7 +203,7 @@ function (ElementEvent $event) {
->push(
new DeindexElement([
'id' => $element->id,
'siteId' => $element->site->id
'siteId' => $element->site ? $element->site->id : null
])
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/jobs/DeindexElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class DeindexElement extends BaseJob
/** @var int */
public $id;

/** @var int */
public int $siteId;
/** @var int|null */
public int|null $siteId;

public function execute($queue): void
{
Expand Down
4 changes: 2 additions & 2 deletions src/jobs/IndexElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class IndexElement extends BaseJob
/** @var int */
public int $id;

/** @var int */
public int $siteId;
/** @var int|null */
public int|null $siteId;

public function execute($queue): void
{
Expand Down
8 changes: 6 additions & 2 deletions src/utilities/ScoutUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ public static function contentHtml(): string
$sites = 'all';
if ($engine->scoutIndex->criteria->siteId != '*') {
$sites = [];
foreach ($engine->scoutIndex->criteria->siteId as $id) {
$sites[] = Craft::$app->getSites()->getSiteById($id);
if (is_array($engine->scoutIndex->criteria->siteId)) {
foreach ($engine->scoutIndex->criteria->siteId as $id) {
$sites[] = Craft::$app->getSites()->getSiteById($id);
}
} else {
$sites = $engine->scoutIndex->criteria->siteId;
}
}
$stats = array_merge($stats, [
Expand Down
6 changes: 5 additions & 1 deletion tests/_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

// Load dotenv?
if (file_exists(CRAFT_BASE_PATH . '/.env')) {
(new Dotenv\Dotenv(CRAFT_BASE_PATH))->load();
if (class_exists(Dotenv\Dotenv::class)) {
// By default, this will allow .env file values to override environment variables
// with matching names. Use `createUnsafeImmutable` to disable this.
Dotenv\Dotenv::createUnsafeMutable(CRAFT_BASE_PATH)->safeLoad();
}
}

// Load and run Craft
Expand Down
12 changes: 6 additions & 6 deletions tests/_craft/config/db.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

return [
'password' => 'root',
'user' => 'root',
'database' => 'scout_testing',
'server' => getenv('DB_SERVER') ?? '127.0.0.1',
'user' => getenv('DB_USER') ?? 'root',
'password' => getenv('DB_PASSWORD') ?? 'root',
'database' => getenv('DB_DATABASE') ?? 'scout_testing',
'schema' => getenv('DB_SCHEMA'),
'tablePrefix' => '',
'driver' => 'mysql',
'port' => 3306,
'schema' => getenv('DB_SCHEMA'),
'server' => '127.0.0.1',
'port' => getenv('DB_PORT') ?? 3306,
];
14 changes: 0 additions & 14 deletions tests/docker-compose.yml

This file was deleted.

6 changes: 5 additions & 1 deletion tests/unit/ScoutUtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ protected function _before()
'engine' => FakeEngine::class,
'indices' => [
ScoutIndex::create('Blog')
->criteria(function($query) {
->criteria(function ($query) {
return $query;
}),
ScoutIndex::create('Blog_with_one_site')
->criteria(function ($query) {
return $query->siteId(1);
}),
],
]);
$scout->init();
Expand Down

0 comments on commit 2140158

Please sign in to comment.