Skip to content

Commit

Permalink
update php and pimcore, fix deprecations (#551)
Browse files Browse the repository at this point in the history
* update php and pimcore, fix deprecations

* update php and pimcore, fix deprecations

* update php and pimcore, fix deprecations

* update php and pimcore, fix deprecations

* update php and pimcore, fix deprecations

* update php and pimcore, fix deprecations
  • Loading branch information
alexz707 authored Jan 21, 2025
1 parent 4ec3748 commit c02cb5d
Show file tree
Hide file tree
Showing 42 changed files with 225 additions and 130 deletions.
File renamed without changes.
155 changes: 77 additions & 78 deletions .github/workflows/codeception.yml
Original file line number Diff line number Diff line change
@@ -1,95 +1,94 @@

name: "Codeception Tests"
name: "Codeception Tests centralised"

on:
pull_request:
branches:
- "*.*"
- "master"
schedule:
- cron: '0 3 * * 1,3,5'
workflow_dispatch:
push:
branches:
- "*.*"
- "master"
- "*_actions"
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
- "feature-*"
pull_request:
types: [opened, synchronize, reopened]

env:
PIMCORE_PROJECT_ROOT: ${{ github.workspace }}
APP_ENV: test
PIMCORE_TEST: 1
PIMCORE_TEST_DB_DSN: "mysql://[email protected]:33006/pimcore_test"
PIMCORE_TEST_REDIS_DSN: "redis://127.0.0.1:63379"
PRIVATE_REPO: ${{ github.event.repository.private }}

jobs:
codeception-tests:
name: "Codeception tests"
runs-on: "ubuntu-20.04"
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
include:
- { php-version: 8.1, database: "mariadb:10.3", dependencies: lowest, experimental: false }
- { php-version: 8.2, database: "mariadb:10.11", dependencies: highest, experimental: false }
- { php-version: 8.3, database: "mariadb:10.11", dependencies: highest, pimcore_version: "11.x-dev as 11.3.9", experimental: true }

services:
redis:
image: redis
ports:
- 63379:6379
mariadb:
image: "${{ matrix.database }}"
ports:
- 33006:3306
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes

setup-matrix:
runs-on: ubuntu-latest
outputs:
php_versions: ${{ steps.parse-php-versions.outputs.php_versions }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
private_repo: ${{ env.PRIVATE_REPO }}
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: imagick
ini-values: display_errors=On, display_startup_errors=On, error_reporting=32767
php-version: "${{ matrix.php-version }}"

- name: Verify MariaDB connection
run: |
cp .github/ci/files/.my.cnf ~/.my.cnf
while ! mysqladmin ping --silent; do
sleep 1
done
- name: "Setup Pimcore environment"
env:
DEPENDENCIES: "${{ matrix.dependencies }}"
run: |
mysql -e "CREATE DATABASE pimcore_test CHARSET=utf8mb4;"
.github/ci/scripts/setup-environment.sh
- name: Checkout code
uses: actions/checkout@v4

- name: "Update Pimcore version"
env:
PIMCORE_VERSION: "${{ matrix.pimcore_version }}"
run: |
if [ ! -z "$PIMCORE_VERSION" ]; then
composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
fi
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
- name: Checkout reusable workflow repo
uses: actions/checkout@v4
with:
dependency-versions: "${{ matrix.dependencies }}"
repository: pimcore/workflows-collection-public
ref: main
path: reusable-workflows

- name: "Test environment infos"
- name: Parse PHP versions from composer.json
id: parse-php-versions
run: |
mysql -e "SELECT VERSION();"
php -i
if [ -f composer.json ]; then
php_versions=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | tr '\n' ',' | sed 's/,$//')
if [ -z "$php_versions" ]; then
echo "No PHP versions found in composer.json"
echo "Setting default PHP value"
echo "php_versions=default" >> $GITHUB_OUTPUT
else
echo "php_versions=$php_versions" >> $GITHUB_OUTPUT
echo "#### php versions #### : $php_versions"
fi
else
echo "composer.json not found"
exit 1
fi
- name: "Sync Metadata Storage"
- name: Set up matrix
id: set-matrix
run: |
bin/console doctrine:migrations:sync-metadata-storage -vvv
php_versions="${{ steps.parse-php-versions.outputs.php_versions }}"
MATRIX_JSON=$(cat reusable-workflows/codeception-tests-configuration/matrix-config.json)
IFS=',' read -ra VERSIONS_ARRAY <<< "$php_versions"
FILTERED_MATRIX_JSON=$(echo $MATRIX_JSON | jq --arg php_versions "$php_versions" '
{
matrix: [
.configs[] |
select(.php_version == $php_versions) |
.matrix[]
]
}')
ENCODED_MATRIX_JSON=$(echo $FILTERED_MATRIX_JSON | jq -c .)
echo "matrix=${ENCODED_MATRIX_JSON}" >> $GITHUB_OUTPUT
- name: "Run Codeception"
run: "vendor/bin/codecept run -c . -vvv --xml"
codeception-tests:
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
uses: pimcore/workflows-collection-public/.github/workflows/reusable-codeception-tests-centralized.yaml@main
with:
APP_ENV: test
PIMCORE_TEST: 1
PRIVATE_REPO: ${{ needs.setup-matrix.outputs.private_repo}}
PHP_VERSION: ${{ matrix.matrix.php-version }}
DATABASE: ${{ matrix.matrix.database }}
SERVER_VERSION: ${{ matrix.matrix.server_version }}
DEPENDENCIES: ${{ matrix.matrix.dependencies }}
EXPERIMENTAL: ${{ matrix.matrix.experimental }}
PIMCORE_VERSION: ${{ matrix.matrix.pimcore_version }}
secrets:
SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
96 changes: 95 additions & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,101 @@ on:
jobs:
static-analysis-phpstan:
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-20.04"name: "Static analysis centralised"

on:
schedule:
- cron: '0 3 * * 1,3,5'
workflow_dispatch:
push:
branches:
- "[0-9]+.[0-9]+"
- "[0-9]+.x"
- "feature-*"
pull_request:
types: [ opened, synchronize, reopened ]


env:
PIMCORE_PROJECT_ROOT: ${{ github.workspace }}
PRIVATE_REPO: ${{ github.event.repository.private }}

jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
php_versions: ${{ steps.parse-php-versions.outputs.php_versions }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
private_repo: ${{ env.PRIVATE_REPO }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Checkout reusable workflow repo
uses: actions/checkout@v4
with:
repository: pimcore/workflows-collection-public
ref: main
path: reusable-workflows

- name: Parse PHP versions from composer.json
id: parse-php-versions
run: |
if [ -f composer.json ]; then
php_versions=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | tr '\n' ',' | sed 's/,$//')
if [ -z "$php_versions" ]; then
echo "No PHP versions found in composer.json"
echo "Setting default PHP value"
echo "php_versions=default" >> $GITHUB_OUTPUT
else
echo "php_versions=$php_versions" >> $GITHUB_OUTPUT
echo "#### php versions #### : $php_versions"
fi
else
echo "composer.json not found"
exit 1
fi
- name: Set up matrix
id: set-matrix
run: |
php_versions="${{ steps.parse-php-versions.outputs.php_versions }}"
MATRIX_JSON=$(cat reusable-workflows/phpstan-configuration/matrix-config.json)
IFS=',' read -ra VERSIONS_ARRAY <<< "$php_versions"
FILTERED_MATRIX_JSON=$(echo $MATRIX_JSON | jq --arg php_versions "$php_versions" '
{
matrix: [
.configs[] |
select(.php_version == $php_versions) |
.matrix[]
]
}')
ENCODED_MATRIX_JSON=$(echo $FILTERED_MATRIX_JSON | jq -c .)
echo "matrix=${ENCODED_MATRIX_JSON}" >> $GITHUB_OUTPUT
static-analysis:
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
uses: pimcore/workflows-collection-public/.github/workflows/reusable-static-analysis-centralized.yaml@main
with:
APP_ENV: test
PIMCORE_TEST: 1
PRIVATE_REPO: ${{ needs.setup-matrix.outputs.private_repo}}
PHP_VERSION: ${{ matrix.matrix.php-version }}
SYMFONY: ${{ matrix.matrix.symfony }}
DEPENDENCIES: ${{ matrix.matrix.dependencies }}
EXPERIMENTAL: ${{ matrix.matrix.experimental }}
PIMCORE_VERSION: ${{ matrix.matrix.pimcore_version }}
COMPOSER_OPTIONS: ${{ matrix.matrix.composer_options }}
secrets:
SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
"ocramius/package-versions": true
}
},
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"doctrine/dbal": "^3.4.2",
"doctrine/migrations": "^3.0.2",
"dragonmantank/cron-expression": "^3.0.2",
Expand All @@ -24,9 +26,9 @@
"pear/archive_tar": "^1.4.14",
"pimcore/newsletter-bundle": "^1.0",
"pimcore/number-sequence-generator": "^2.0",
"pimcore/admin-ui-classic-bundle": "^1.0",
"pimcore/admin-ui-classic-bundle": "^1.0 || ^2.0",
"pimcore/object-merger": "^4.0",
"pimcore/pimcore": "^11.2",
"pimcore/pimcore": "^11.2 || ^12.0",
"pimcore/search-query-parser": "^1.3",
"pimcore/personalization-bundle": "^1.0",
"symfony/asset": "^6.2",
Expand All @@ -48,7 +50,7 @@
"codeception/module-symfony": "^3.1.0",
"codeception/phpunit-wrapper": "^9",
"php-http/guzzle7-adapter": "^0.1.1",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan": "^1.12.15",
"phpstan/phpstan-symfony": "^1.2.14",
"phpunit/phpunit": "^9.5"
},
Expand Down
2 changes: 1 addition & 1 deletion src/ActivityStore/ActivityStoreInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function insertActivityIntoStore(ActivityInterface $activity);
*
* @return ActivityStoreEntryInterface
*/
public function updateActivityInStore(ActivityInterface $activity, ActivityStoreEntryInterface $entry = null);
public function updateActivityInStore(ActivityInterface $activity, ?ActivityStoreEntryInterface $entry = null);

/**
*
Expand Down
4 changes: 2 additions & 2 deletions src/ActivityStore/MariaDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function insertActivityIntoStore(ActivityInterface $activity)
*
* @throws \Exception
*/
public function updateActivityInStore(ActivityInterface $activity, ActivityStoreEntryInterface $entry = null)
public function updateActivityInStore(ActivityInterface $activity, ?ActivityStoreEntryInterface $entry = null)
{
if (is_null($entry)) {
$entry = $this->getEntryForActivity($activity);
Expand Down Expand Up @@ -104,7 +104,7 @@ public function updateActivityStoreEntry(ActivityStoreEntryInterface $entry, $up
$this->saveActivityStoreEntry($entry);
}

protected function saveActivityStoreEntry(ActivityStoreEntryInterface $entry, ActivityInterface $activity = null)
protected function saveActivityStoreEntry(ActivityStoreEntryInterface $entry, ?ActivityInterface $activity = null)
{
$db = Db::get();
$time = time();
Expand Down
4 changes: 2 additions & 2 deletions src/ActivityStore/SqlActivityStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ abstract protected function getAttributeInsertData(ActivityInterface $activity);
*/
abstract protected function getActivityStoreConnection();

protected function saveActivityStoreEntry(ActivityStoreEntryInterface $entry, ActivityInterface $activity = null)
protected function saveActivityStoreEntry(ActivityStoreEntryInterface $entry, ?ActivityInterface $activity = null)
{
$db = Db::get();
$time = time();
Expand Down Expand Up @@ -173,7 +173,7 @@ public function getAvailableActivityTypes()
*
* @throws \Exception
*/
public function updateActivityInStore(ActivityInterface $activity, ActivityStoreEntryInterface $entry = null)
public function updateActivityInStore(ActivityInterface $activity, ?ActivityStoreEntryInterface $entry = null)
{
if (null === $entry) {
$entry = $this->getEntryForActivity($activity);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function getJsConfigFeatures(): array
/**
* Build object paginator for filtered list
*/
protected function buildPaginator(Request $request, mixed $data, int $defaultPageSize = null): PaginationInterface
protected function buildPaginator(Request $request, mixed $data, ?int $defaultPageSize = null): PaginationInterface
{
if (is_null($defaultPageSize)) {
$defaultPageSize = $this->defaultPageSize;
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Rest/AbstractRestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected function createErrorResponse($data = null, $status = Response::HTTP_BA
);
}

protected function createNotFoundResponseException($message = null, \Exception $previous = null)
protected function createNotFoundResponseException($message = null, ?\Exception $previous = null)
{
return new ResponseException($this->createErrorResponse(
$message ?: Response::$statusTexts[Response::HTTP_NOT_FOUND],
Expand Down
2 changes: 1 addition & 1 deletion src/CustomerList/ExporterManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function hasExporter($key)
*
* @return ExporterInterface
*/
public function buildExporter($key, Listing\Concrete $listing = null)
public function buildExporter($key, ?Listing\Concrete $listing = null)
{
if (!$this->hasExporter($key)) {
throw new \InvalidArgumentException(sprintf('Exporter %s is not defined', $key));
Expand Down
2 changes: 1 addition & 1 deletion src/CustomerList/ExporterManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function hasExporter($key);
*
* @return ExporterInterface
*/
public function buildExporter($key, Listing\Concrete $listing = null);
public function buildExporter($key, ?Listing\Concrete $listing = null);

/**
*
Expand Down
Loading

0 comments on commit c02cb5d

Please sign in to comment.