diff --git a/composer.json b/composer.json index d269af9..2c3413b 100644 --- a/composer.json +++ b/composer.json @@ -33,16 +33,16 @@ "ext-json": "*", "yiisoft/cache": "^2.0|^3.0", "yiisoft/arrays": "^2.0|^3.0", - "yiisoft/db": "^1.0", + "yiisoft/db": "^2.0", "yiisoft/translator": "^2.2|^3.0" }, "require-dev": { "maglnet/composer-require-checker": "^4.2", "phpunit/phpunit": "^9.6|^10.5", "rector/rector": "^2.0", - "roave/infection-static-analysis-plugin": "^1.25|^1.34", + "roave/infection-static-analysis-plugin": "^1.40", "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^4.8|^5.20" + "vimeo/psalm": "^6.14.2" }, "autoload": { "psr-4": { diff --git a/src/MessageSource.php b/src/MessageSource.php index a0acf5f..51b3837 100644 --- a/src/MessageSource.php +++ b/src/MessageSource.php @@ -5,10 +5,10 @@ namespace Yiisoft\Translator\Message\Db; use JsonException; +use Psr\SimpleCache\CacheInterface; use RuntimeException; use Throwable; use Yiisoft\Arrays\ArrayHelper; -use Yiisoft\Cache\CacheInterface; use Yiisoft\Db\Connection\ConnectionInterface; use Yiisoft\Db\Exception\Exception; use Yiisoft\Db\Exception\InvalidArgumentException; @@ -118,7 +118,7 @@ public function write(string $category, string $locale, array $messages): void /** @psalm-var array|false $result */ $result = $this->db ->createCommand() - ->insertWithReturningPks( + ->insertReturningPks( $this->sourceMessageTable, [ 'category' => $category, @@ -146,7 +146,7 @@ public function write(string $category, string $locale, array $messages): void if ($needUpdate || !isset($translatedMessages[$messageId])) { $result = $this->db ->createCommand() - ->insertWithReturningPks( + ->insertReturningPks( $this->messageTable, [ 'id' => $sourceMessages[$messageId], @@ -199,10 +199,11 @@ private function readFromDb(string $category, string $locale): array ->innerJoin( ['td' => $this->messageTable], [ - 'td.id' => new Expression('[[ts.id]]'), - 'ts.category' => $category, + 'td.id' => new Expression('[[ts]].[[id]]'), + 'ts.category' => new Expression(':messageCategory'), ] ) + ->params([':messageCategory' => $category]) ->where(['locale' => $locale]); /** @psalm-var array> $messages */