Skip to content

Commit

Permalink
Merge pull request #57 from arsonik/php74
Browse files Browse the repository at this point in the history
Php 7.4
  • Loading branch information
Greg authored Mar 30, 2020
2 parents 2512218 + 76b12a0 commit c97f029
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 32 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
}
},
"require": {
"php": "^7.1",
"doctrine/dbal": "^2.5.2",
"php": "^7.4",
"doctrine/dbal": "^2.10.1",
"psr/cache": "^1.0",
"cache/apcu-adapter": "^1.0"
},
Expand Down
15 changes: 8 additions & 7 deletions config/docker/php/behat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM isanosyan/php:7.1-cli-base
FROM php:7.4-cli

RUN apt-get update
RUN apt-get install -y git file libpq-dev php-apcu php7.1-dev php7.1-mbstring php7.1-mysql php7.1-pgsql
RUN cd /tmp/ && git clone git://github.com/xdebug/xdebug.git
RUN cd /tmp/xdebug && git checkout XDEBUG_2_5_5 && phpize && ./configure --enable-xdebug && make && make install
RUN apt-get update && apt-get install -y libpq-dev \
&& docker-php-ext-configure pgsql \
&& docker-php-ext-install -j$(nproc) pcntl pdo_pgsql pdo_mysql mysqli \
&& docker-php-ext-enable pcntl pdo_pgsql pdo_mysql mysqli

COPY apc.ini /etc/php/7.1/mods-available/apcu.ini
RUN phpenmod -v ALL -s ALL apcu
RUN pecl install redis apcu xdebug \
&& docker-php-ext-enable redis xdebug apcu

COPY apc.ini /etc/php/7.4/mods-available/apcu.ini

ENTRYPOINT ["php", "/scripts/vendor/bin/behat"]

Expand Down
5 changes: 3 additions & 2 deletions config/docker/php/composer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM php:7.1-fpm-alpine
FROM php:7.4-cli

RUN docker-php-ext-install mbstring
RUN apt-get update && apt-get install -y libonig-dev zip \
&& docker-php-ext-install mbstring

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir /usr/local/bin --filename composer

Expand Down
2 changes: 1 addition & 1 deletion config/docker/php/vendor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.1-fpm-alpine
FROM php:7.4-cli

VOLUME /scripts/vendor/

Expand Down
4 changes: 1 addition & 3 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,8 @@ public function theLastQuerySucceededOn($connectionName): void
{
if ($this->connections[$connectionName]['last-result'] === null) {
$lastError = $this->connections[$connectionName]['last-error'];
if ($lastError instanceof \Exception) {
if ($lastError instanceof \Throwable) {
$message = $lastError->getMessage();
} else if ($lastError !== null) {
$message = print_r($lastError, true);
} else {
$message = print_r($lastError, true);
}
Expand Down
14 changes: 6 additions & 8 deletions features/bootstrap/MySQLContext.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?php

use Doctrine\DBAL\DriverManager;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\DriverException as DDriverException;
use Doctrine\DBAL\Exception\DriverException as EDriverException;
use Ez\DbLinker\Driver\Connection\RetryConnection;

trait MySQLContext
{
private function masterParams($username = null, $password = '') {
protected function masterParams($username = null, $password = '') {
$params = [
'host' => getenv('DBLINKER_MYSQL_MASTER_1_PORT_3306_TCP_ADDR'),
'user' => getenv('DBLINKER_MYSQL_MASTER_1_ENV_MYSQL_USER'),
Expand Down Expand Up @@ -49,7 +47,7 @@ private function defaultDatabaseName()
return getenv('DBLINKER_MYSQL_MASTER_1_ENV_MYSQL_DATABASE');
}

private function activeConnectionsCount()
protected function activeConnectionsCount()
{
$connection = $this->rootConnection();
gc_collect_cycles();
Expand Down Expand Up @@ -94,12 +92,12 @@ public function clearConnections()
gc_collect_cycles();
}

private function retryStrategy($n)
protected function retryStrategy($n)
{
return new MysqlRetryStrategy($n);
}

private function errorCode(Exception $exception)
protected function errorCode(Exception $exception)
{
if ($exception instanceof DBALException) {
$exception = $exception->getPrevious();
Expand All @@ -124,7 +122,7 @@ private function prepareSql($sql)
return $sql;
}

private function errorToCode($error)
protected function errorToCode($error)
{
$errors = [
"BAD_DB" => 1049,
Expand All @@ -149,7 +147,7 @@ class MysqlRetryStrategy extends Ez\DbLinker\RetryStrategy\MysqlRetryStrategy
private $lastError = null;
private $handlers = [];

public function shouldRetry(Exception $exception, RetryConnection $connection) {
public function shouldRetry(Exception $exception, RetryConnection $connection): bool {
$this->lastError = $exception;
return array_reduce($this->handlers, function($retry, Closure $handler) use ($exception, $connection) {
return $retry || $handler($exception, $connection);
Expand Down
16 changes: 8 additions & 8 deletions features/bootstrap/PostgreSQLContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

trait PostgreSQLContext
{
private function masterParams($username = null, $password = '') {
protected function masterParams($username = null, $password = '') {
$params = [
'host' => getenv('DBLINKER_POSTGRESQL_MASTER_1_PORT_5432_TCP_ADDR'),
'user' => getenv('DBLINKER_POSTGRESQL_MASTER_1_ENV_POSTGRES_USER'),
Expand Down Expand Up @@ -46,7 +46,7 @@ private function defaultDatabaseName()
return getenv('DBLINKER_POSTGRESQL_MASTER_1_ENV_POSTGRES_DB');
}

private function activeConnectionsCount()
protected function activeConnectionsCount()
{
return 0;
}
Expand Down Expand Up @@ -75,13 +75,13 @@ public function clearConnections()
];
}

private function retryStrategy($n)
protected function retryStrategy($n)
{
return new PostgreSQLRetryStrategy($n);
}


private function errorCode(Exception $exception)
protected function errorCode(Exception $exception)
{
if(preg_match("/SQLSTATE\[(?<errorCode>[A-Z0-9]*)\]/", $exception->getMessage(), $matches)) {
$code = $matches["errorCode"];
Expand All @@ -94,12 +94,12 @@ private function errorCode(Exception $exception)

private function retryDriverClass()
{
return "Ez\DbLinker\Driver\PostgresqlRetryDriver";
return Ez\DbLinker\Driver\PostgresqlRetryDriver::class;
}

private function masterSlaveDriverClass()
{
return "Ez\DbLinker\Driver\PostgresqlMasterSlavesDriver";
return Ez\DbLinker\Driver\PostgresqlMasterSlavesDriver::class;
}

private function prepareSql($sql)
Expand All @@ -110,7 +110,7 @@ private function prepareSql($sql)
return $sql;
}

private function errorToCode($error)
protected function errorToCode($error)
{
if ($error === null) {
return;
Expand Down Expand Up @@ -138,7 +138,7 @@ class PostgreSQLRetryStrategy extends Ez\DbLinker\RetryStrategy\PostgreSQLRetryS
public function shouldRetry(
Exception $exception,
RetryConnection $connection
) {
): bool {
$this->lastError = $exception;
return array_reduce($this->handlers, function($retry, Closure $handler) use ($exception, $connection) {
return $retry || $handler($exception, $connection);
Expand Down
2 changes: 1 addition & 1 deletion features/master-slave.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@master-slaves
Feature: Master / Slaves

Background:
Background:
Given a master-slaves connection "conn" with 3 slaves

Scenario: Insert a row on master
Expand Down

0 comments on commit c97f029

Please sign in to comment.