Skip to content

Commit

Permalink
Added PHP 8 support and DBAL 3 support (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremycr authored Mar 23, 2021
1 parent 8bb55b1 commit b191e33
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 56 deletions.
55 changes: 31 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,64 +23,68 @@ env:
matrix:
fast_finish: true
include:
- php: '7.1'
- php: '7.2'
- php: '7.3'
- php: '7.4'
- php: '8.0'

# Enable code coverage with the previous supported PHP version
- php: '7.3'
- php: '7.4'
env:
- SYMFONY_VERSION=3.4.*
- COVERALLS_ENABLED="true"
- PHPUNIT_FLAGS="-v --coverage-text --coverage-clover var/build/clover.xml"

# Enable code coverage with the latest supported PHP version
- php: '7.4'
- php: '8.0'
env:
- SYMFONY_VERSION=3.4.*
- COVERALLS_ENABLED="true"
- PHPUNIT_FLAGS="-v --coverage-text --coverage-clover var/build/clover.xml"

# Minimum supported dependencies with the latest and oldest supported PHP versions
- php: '7.1'
env:
- COMPOSER_FLAGS="--prefer-lowest"
- php: '7.3'
env:
- COMPOSER_FLAGS="--prefer-lowest"
# Incompatibility between lowest symfony testing utils and phpunit
# - php: '8.0'
# env:
# - COMPOSER_FLAGS="--prefer-lowest"

# Test each supported Symfony version with lowest supported PHP version
- php: '7.1'
- php: '7.3'
env:
- SYMFONY_VERSION=3.4.*
- php: '7.1'
env:
- SYMFONY_VERSION=4.3.*
- php: '7.1'
- php: '7.3'
env:
- SYMFONY_VERSION=4.4.*
- php: '7.2'
- php: '7.3'
env:
- COVERALLS_ENABLED="true"
- PHPUNIT_FLAGS="-v --coverage-text --coverage-clover var/build/clover.xml"
- SYMFONY_VERSION=5.0.*

- SYMFONY_VERSION=5.2.*
# Test unsupported versions of Symfony
- php: '7.1'
- php: '7.3'
env:
- SYMFONY_VERSION=4.1.*
- php: '7.1'
- php: '7.3'
env:
- SYMFONY_VERSION=4.2.*


# Test upcoming Symfony versions with lowest supported PHP version and dev dependencies
- php: '7.2'
- php: '7.3'
env:
- SYMFONY_VERSION=4.3.*
- php: '7.3'
env:
- SYMFONY_VERSION=5.0.*
- php: '7.3'
env:
- STABILITY=dev
- SYMFONY_VERSION=5.1.*

# Test upcoming Symfony versions with lowest supported PHP version and dev dependencies
# - php: '7.2'
# env:
# - STABILITY=dev
# - SYMFONY_VERSION=5.3.*

# Test upcoming PHP versions with dev dependencies
#- php: '7.5snapshot'
# env:
Expand All @@ -101,6 +105,9 @@ matrix:
- env:
- STABILITY=dev
- SYMFONY_VERSION=5.1.*
- env:
- STABILITY=dev
- SYMFONY_VERSION=5.2.*

before_install:
- if [[ "$SYMFONY_VERSION" != "" ]]; then
Expand All @@ -114,11 +121,11 @@ before_install:
phpenv config-rm xdebug.ini || true;
fi
- if [[ "$COVERALLS_ENABLED" == "true" ]]; then
travis_retry composer require --dev satooshi/php-coveralls:^2.0 --no-update $COMPOSER_FLAGS;
travis_retry composer require --dev php-coveralls/php-coveralls:^2.0 --no-update $COMPOSER_FLAGS;
fi

install:
- travis_retry composer update --prefer-dist --no-interaction --no-suggest --no-progress --ansi $COMPOSER_FLAGS
- travis_retry composer update --prefer-dist --no-interaction --no-progress --ansi $COMPOSER_FLAGS

script: ./vendor/bin/phpunit $PHPUNIT_FLAGS

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Version 3.0.0

* Added PHP 8 support
* PHP minimum requirements bumped to 7.3
* Added Doctrine DBAL 3 support
* Doctrine DBAL minimum requirements bumped to 2.12

# Version 2.2.0

* Improve logging Dataflow job
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
}
},
"require": {
"php": "^7.1",
"php": "^7.3||^8.0",
"ext-json": "*",
"doctrine/dbal": "^2.0",
"doctrine/dbal": "^2.12||^3.0",
"doctrine/doctrine-bundle": "^1.0||^2.0",
"psr/log": "^1.1",
"symfony/config": "^3.4||^4.0||^5.0",
Expand Down
39 changes: 20 additions & 19 deletions src/Repository/JobRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use CodeRhapsodie\DataflowBundle\Entity\Job;
use CodeRhapsodie\DataflowBundle\Entity\ScheduledDataflow;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Query\QueryBuilder;

/**
Expand All @@ -21,15 +22,15 @@ class JobRepository
public const TABLE_NAME = 'cr_dataflow_job';

private const FIELDS_TYPE = [
'id' => \PDO::PARAM_INT,
'status' => \PDO::PARAM_INT,
'label' => \PDO::PARAM_STR,
'dataflow_type' => \PDO::PARAM_STR,
'options' => \PDO::PARAM_STR,
'id' => ParameterType::INTEGER,
'status' => ParameterType::INTEGER,
'label' => ParameterType::STRING,
'dataflow_type' => ParameterType::STRING,
'options' => ParameterType::STRING,
'requested_date' => 'datetime',
'scheduled_dataflow_id' => \PDO::PARAM_INT,
'count' => \PDO::PARAM_INT,
'exceptions' => \PDO::PARAM_STR,
'scheduled_dataflow_id' => ParameterType::INTEGER,
'count' => ParameterType::INTEGER,
'exceptions' => ParameterType::STRING,
'start_time' => 'datetime',
'end_time' => 'datetime',
];
Expand All @@ -51,7 +52,7 @@ public function find(int $jobId)
{
$qb = $this->createQueryBuilder();
$qb
->andWhere($qb->expr()->eq('id', $qb->createNamedParameter($jobId, \PDO::PARAM_INT)))
->andWhere($qb->expr()->eq('id', $qb->createNamedParameter($jobId, ParameterType::INTEGER)))
;

return $this->returnFirstOrNull($qb);
Expand All @@ -62,12 +63,12 @@ public function findOneshotDataflows(): iterable
$qb = $this->createQueryBuilder();
$qb
->andWhere($qb->expr()->isNull('scheduled_dataflow_id'))
->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, \PDO::PARAM_INT)));
->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, ParameterType::INTEGER)));
$stmt = $qb->execute();
if (0 === $stmt->rowCount()) {
return [];
}
while (false !== ($row = $stmt->fetch(\PDO::FETCH_ASSOC))) {
while (false !== ($row = $stmt->fetchAssociative())) {
yield Job::createFromArray($this->initDateTime($this->initArray($row)));
}
}
Expand All @@ -76,8 +77,8 @@ public function findPendingForScheduledDataflow(ScheduledDataflow $scheduled): ?
{
$qb = $this->createQueryBuilder();
$qb
->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($scheduled->getId(), \PDO::PARAM_INT)))
->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, \PDO::PARAM_INT)));
->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($scheduled->getId(), ParameterType::INTEGER)))
->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, ParameterType::INTEGER)));

return $this->returnFirstOrNull($qb);
}
Expand All @@ -86,7 +87,7 @@ public function findNextPendingDataflow(): ?Job
{
$qb = $this->createQueryBuilder();
$qb->andWhere($qb->expr()->lte('requested_date', $qb->createNamedParameter(new \DateTime(), 'datetime')))
->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, \PDO::PARAM_INT)))
->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(Job::STATUS_PENDING, ParameterType::INTEGER)))
->orderBy('requested_date', 'ASC')
->setMaxResults(1)
;
Expand All @@ -97,7 +98,7 @@ public function findNextPendingDataflow(): ?Job
public function findLastForDataflowId(int $dataflowId): ?Job
{
$qb = $this->createQueryBuilder();
$qb->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($dataflowId, \PDO::PARAM_INT)))
$qb->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($dataflowId, ParameterType::INTEGER)))
->orderBy('requested_date', 'DESC')
->setMaxResults(1)
;
Expand All @@ -115,22 +116,22 @@ public function findLatests(): iterable
if (0 === $stmt->rowCount()) {
return [];
}
while (false !== ($row = $stmt->fetch(\PDO::FETCH_ASSOC))) {
while (false !== ($row = $stmt->fetchAssociative())) {
yield Job::createFromArray($row);
}
}

public function findForScheduled(int $id): iterable
{
$qb = $this->createQueryBuilder();
$qb->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($id, \PDO::PARAM_INT)))
$qb->andWhere($qb->expr()->eq('scheduled_dataflow_id', $qb->createNamedParameter($id, ParameterType::INTEGER)))
->orderBy('requested_date', 'DESC')
->setMaxResults(20);
$stmt = $qb->execute();
if (0 === $stmt->rowCount()) {
return [];
}
while (false !== ($row = $stmt->fetch(\PDO::FETCH_ASSOC))) {
while (false !== ($row = $stmt->fetchAssociative())) {
yield Job::createFromArray($row);
}
}
Expand Down Expand Up @@ -172,6 +173,6 @@ private function returnFirstOrNull(QueryBuilder $qb): ?Job
return null;
}

return Job::createFromArray($this->initDateTime($this->initArray($stmt->fetch(\PDO::FETCH_ASSOC))));
return Job::createFromArray($this->initDateTime($this->initArray($stmt->fetchAssociative())));
}
}
23 changes: 12 additions & 11 deletions src/Repository/ScheduledDataflowRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use CodeRhapsodie\DataflowBundle\Entity\ScheduledDataflow;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Query\QueryBuilder;

/**
Expand All @@ -20,13 +21,13 @@ class ScheduledDataflowRepository
public const TABLE_NAME = 'cr_dataflow_scheduled';

private const FIELDS_TYPE = [
'id' => \PDO::PARAM_INT,
'label' => \PDO::PARAM_STR,
'dataflow_type' => \PDO::PARAM_STR,
'options' => \PDO::PARAM_STR,
'frequency' => \PDO::PARAM_STR,
'id' => ParameterType::INTEGER,
'label' => ParameterType::STRING,
'dataflow_type' => ParameterType::STRING,
'options' => ParameterType::STRING,
'frequency' => ParameterType::STRING,
'next' => 'datetime',
'enabled' => \PDO::PARAM_BOOL,
'enabled' => ParameterType::BOOLEAN,
];
/**
* @var \Doctrine\DBAL\Connection
Expand Down Expand Up @@ -58,15 +59,15 @@ public function findReadyToRun(): iterable
if (0 === $stmt->rowCount()) {
return [];
}
while (false !== ($row = $stmt->fetch(\PDO::FETCH_ASSOC))) {
while (false !== ($row = $stmt->fetchAssociative())) {
yield ScheduledDataflow::createFromArray($this->initDateTime($this->initArray($row)));
}
}

public function find(int $scheduleId): ?ScheduledDataflow
{
$qb = $this->createQueryBuilder();
$qb->andWhere($qb->expr()->eq('id', $qb->createNamedParameter($scheduleId, \PDO::PARAM_INT)))
$qb->andWhere($qb->expr()->eq('id', $qb->createNamedParameter($scheduleId, ParameterType::INTEGER)))
->setMaxResults(1)
;

Expand All @@ -82,7 +83,7 @@ public function findAllOrderedByLabel(): iterable
if (0 === $stmt->rowCount()) {
return [];
}
while (false !== ($row = $stmt->fetch(\PDO::FETCH_ASSOC))) {
while (false !== ($row = $stmt->fetchAssociative())) {
yield ScheduledDataflow::createFromArray($this->initDateTime($this->initOptions($row)));
}
}
Expand All @@ -96,7 +97,7 @@ public function listAllOrderedByLabel(): array
->orderBy('w.label', 'ASC')
->groupBy('w.id');

return $query->execute()->fetchAll(\PDO::FETCH_ASSOC);
return $query->execute()->fetchAllAssociative();
}

public function save(ScheduledDataflow $scheduledDataflow)
Expand Down Expand Up @@ -147,6 +148,6 @@ private function returnFirstOrNull(QueryBuilder $qb): ?ScheduledDataflow
return null;
}

return ScheduledDataflow::createFromArray($this->initDateTime($this->initArray($stmt->fetch(\PDO::FETCH_ASSOC))));
return ScheduledDataflow::createFromArray($this->initDateTime($this->initArray($stmt->fetchAssociative())));
}
}

0 comments on commit b191e33

Please sign in to comment.