Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bail early when connecting to Redis throws an Exception #285

Merged
merged 3 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,33 @@ jobs:
steps:
- checkout
- run: echo $(openssl rand -hex 8) > /tmp/WORDPRESS_ADMIN_PASSWORD
- run: |
echo 'export TERMINUS_ENV=ci-$CIRCLE_BUILD_NUM' >> $BASH_ENV
echo 'export TERMINUS_SITE=wp-redis' >> $BASH_ENV
echo 'export SITE_ENV=wp-redis.ci-$CIRCLE_BUILD_NUM' >> $BASH_ENV
echo 'export WORDPRESS_ADMIN_USERNAME=pantheon' >> $BASH_ENV
echo 'export [email protected]' >> $BASH_ENV
echo 'export WORDPRESS_ADMIN_PASSWORD=$(cat /tmp/WORDPRESS_ADMIN_PASSWORD)' >> $BASH_ENV
source $BASH_ENV
- run: echo "StrictHostKeyChecking no" >> "$HOME/.ssh/config"
- run: |
if [ -z "$GITHUB_TOKEN" ]; then
echo "GITHUB_TOKEN environment variables missing; assuming unauthenticated build"
exit 0
fi
echo "Setting GitHub OAuth token with suppressed ouput"
{
composer config -g github-oauth.github.com $GITHUB_TOKEN
} &> /dev/null
- run: |
if [ -z "$TERMINUS_TOKEN" ]; then
echo "TERMINUS_TOKEN environment variables missing; assuming unauthenticated build"
exit 0
fi
composer install --prefer-dist
terminus auth:login --machine-token=$TERMINUS_TOKEN
- run: ./bin/behat-prepare.sh
- run: ./bin/behat-test.sh --strict
- run:
command: ./bin/behat-cleanup.sh
when: always
# - run: |
# echo 'export TERMINUS_ENV=ci-$CIRCLE_BUILD_NUM' >> $BASH_ENV
# echo 'export TERMINUS_SITE=wp-redis' >> $BASH_ENV
# echo 'export SITE_ENV=wp-redis.ci-$CIRCLE_BUILD_NUM' >> $BASH_ENV
# echo 'export WORDPRESS_ADMIN_USERNAME=pantheon' >> $BASH_ENV
# echo 'export [email protected]' >> $BASH_ENV
# echo 'export WORDPRESS_ADMIN_PASSWORD=$(cat /tmp/WORDPRESS_ADMIN_PASSWORD)' >> $BASH_ENV
# source $BASH_ENV
# - run: echo "StrictHostKeyChecking no" >> "$HOME/.ssh/config"
# - run: |
# if [ -z "$GITHUB_TOKEN" ]; then
# echo "GITHUB_TOKEN environment variables missing; assuming unauthenticated build"
# exit 0
# fi
# echo "Setting GitHub OAuth token with suppressed ouput"
# {
# composer config -g github-oauth.github.com $GITHUB_TOKEN
# } &> /dev/null
# - run: |
# if [ -z "$TERMINUS_TOKEN" ]; then
# echo "TERMINUS_TOKEN environment variables missing; assuming unauthenticated build"
# exit 0
# fi
# composer install --prefer-dist
# terminus auth:login --machine-token=$TERMINUS_TOKEN
# - run: ./bin/behat-prepare.sh
# - run: ./bin/behat-test.sh --strict
# - run:
# command: ./bin/behat-cleanup.sh
# when: always
4 changes: 4 additions & 0 deletions object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,8 @@ protected function _connect_redis() {
$this->redis = call_user_func_array( $client_connection, array( $client_parameters ) );
} catch ( Exception $e ) {
$this->_exception_handler( $e );
$this->is_redis_connected = false;
return $this->is_redis_connected;
}

$keys_methods = array(
Expand All @@ -1031,6 +1033,8 @@ protected function _connect_redis() {
call_user_func_array( $setup_connection, array( $this->redis, $client_parameters, $keys_methods ) );
} catch ( Exception $e ) {
$this->_exception_handler( $e );
$this->is_redis_connected = false;
return $this->is_redis_connected;
}

$this->is_redis_connected = $this->redis->isConnected();
Expand Down
3 changes: 0 additions & 3 deletions tests/phpunit/test-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -1336,9 +1336,6 @@ public function test_setup_connection_throws_exception() {
if ( ! class_exists( 'Redis' ) ) {
$this->markTestSkipped( 'PHPRedis extension not available.' );
}
if ( version_compare( PHP_VERSION, '7.4-alpha' ) >= 0 ) {
$this->markTestSkipped( 'Test fails unexpectedly in PHP 7.4' );
}

$redis = $this->getMockBuilder( 'Redis' )->getMock();
$redis->method( 'select' )
Expand Down