Merge branch '4.4' into 5.2

* 4.4:
  [Cache] Add server-commands support for Predis Replication Environments
  Speedup psalm
This commit is contained in:
Nicolas Grekas 2021-02-26 00:54:56 +01:00
commit 2068652fc9
7 changed files with 277 additions and 291 deletions

View File

@ -8,8 +8,11 @@ on:
paths:
- 'src/Symfony/Component/Intl/Resources/data/**'
jobs:
defaults:
run:
shell: bash
jobs:
tests:
name: Tests (intl-data)
runs-on: ubuntu-latest

View File

@ -8,8 +8,11 @@ on:
paths:
- 'src/Symfony/Bridge/PhpUnit/**'
jobs:
defaults:
run:
shell: bash
jobs:
lint:
name: Lint
runs-on: ubuntu-latest

View File

@ -3,6 +3,10 @@ name: Static analysis
on:
pull_request: ~
defaults:
run:
shell: bash
jobs:
psalm:
name: Psalm
@ -17,81 +21,38 @@ jobs:
ini-values: "memory_limit=-1"
coverage: none
- name: Checkout PR
uses: actions/checkout@v2
with:
path: pr
- name: Checkout base
- name: Checkout target branch
uses: actions/checkout@v2
with:
ref: ${{ github.base_ref }}
path: base
- name: Checkout PR
uses: actions/checkout@v2
- name: Configure composer
run: |
cd base
COMPOSER_HOME="$(composer config home)"
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
echo "COMPOSER_ROOT_VERSION=$(grep -m1 SYMFONY_VERSION .travis.yml | grep -o '[0-9.x]*').x-dev" >> $GITHUB_ENV
- name: Determine composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ github.base_ref }}
restore-keys: composer-
- name: Install Psalm
run: |
composer require psalm/phar
cp ./vendor/bin/psalm.phar base/psalm.phar
cp ./vendor/bin/psalm.phar pr/psalm.phar
- name: Install dependencies for base
run: |
cd base
echo "::group::modify composer.json"
composer remove symfony/phpunit-bridge --no-interaction --no-update
composer require --no-update phpunit/phpunit php-http/discovery psr/event-dispatcher
composer remove --no-update --no-interaction symfony/phpunit-bridge
composer require --no-update psalm/phar phpunit/phpunit php-http/discovery psr/event-dispatcher
echo "::endgroup::"
echo "::group::composer update"
composer update --no-progress --ansi
git checkout composer.json
echo "::endgroup::"
./vendor/bin/psalm.phar --version
- name: Generate Psalm baseline
run: |
cd base
./psalm.phar --set-baseline=.github/psalm/psalm.baseline.xml --no-progress
- name: Copy baseline
run: |
cp base/.github/psalm/psalm.baseline.xml pr/.github/psalm/psalm.baseline.xml
- name: Install dependencies for PR
run: |
cd pr
echo "::group::modify composer.json"
composer remove symfony/phpunit-bridge --no-interaction --no-update
composer require --no-update phpunit/phpunit php-http/discovery psr/event-dispatcher
echo "::endgroup::"
echo "::group::composer update"
composer update --no-progress --ansi
echo "::endgroup::"
- name: Cache Psalm
uses: actions/cache@v2
with:
path: pr/.github/psalm/cache/
key: psalm-${{ github.base_ref }}
restore-keys: psalm-
git checkout -m ${{ github.base_ref }}
./vendor/bin/psalm.phar --set-baseline=.github/psalm/psalm.baseline.xml --no-progress
git checkout -m FETCH_HEAD
- name: Psalm
run: |
cd pr
./psalm.phar --version
./psalm.phar --output-format=github --no-progress
./vendor/bin/psalm.phar --output-format=github --no-progress

View File

@ -4,8 +4,11 @@ on:
push:
pull_request:
jobs:
defaults:
run:
shell: bash
jobs:
integration:
name: Integration
runs-on: ubuntu-latest

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\Cache\Adapter;
use Predis\Connection\Aggregate\ClusterInterface;
use Predis\Connection\Aggregate\PredisCluster;
use Predis\Connection\Aggregate\ReplicationInterface;
use Predis\Response\Status;
use Symfony\Component\Cache\Exception\InvalidArgumentException;
use Symfony\Component\Cache\Exception\LogicException;
@ -282,7 +283,14 @@ EOLUA;
return $this->redisEvictionPolicy;
}
foreach ($this->getHosts() as $host) {
$hosts = $this->getHosts();
$host = reset($hosts);
if ($host instanceof \Predis\Client && $host->getConnection() instanceof ReplicationInterface) {
// Predis supports info command only on the master in replication environments
$hosts = [$host->getClientFor('master')];
}
foreach ($hosts as $host) {
$info = $host->info('Memory');
$info = $info['Memory'] ?? $info;

View File

@ -14,6 +14,7 @@ namespace Symfony\Component\Cache\Traits;
use Predis\Command\Redis\UNLINK;
use Predis\Connection\Aggregate\ClusterInterface;
use Predis\Connection\Aggregate\RedisCluster;
use Predis\Connection\Aggregate\ReplicationInterface;
use Predis\Response\Status;
use Symfony\Component\Cache\Exception\CacheException;
use Symfony\Component\Cache\Exception\InvalidArgumentException;
@ -368,7 +369,14 @@ trait RedisTrait
$evalArgs = [[$namespace], 0];
}
foreach ($this->getHosts() as $host) {
$hosts = $this->getHosts();
$host = reset($hosts);
if ($host instanceof \Predis\Client && $host->getConnection() instanceof ReplicationInterface) {
// Predis supports info command only on the master in replication environments
$hosts = [$host->getClientFor('master')];
}
foreach ($hosts as $host) {
if (!isset($namespace[0])) {
$cleared = $host->flushDb() && $cleared;
continue;