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

[FEATURE] TYPO3 13.1 compatibility #18

Merged
merged 16 commits into from
Jun 10, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/composer/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.json') }}
Expand Down
90 changes: 58 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
name: Testing and linting

on:
push:
branches:
- main
- develop
pull_request:
workflow_dispatch:
schedule:
Expand All @@ -9,148 +14,169 @@ on:
env:
TYPO3_EXTENSION_KEY: html5mediakit
MAIN_PHP_VERSION: 8.3
CI: true

jobs:
"composer-validate":
name: "Composer validate"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: "${{ env.MAIN_PHP_VERSION }}"
- run: |
bash .Build/bin/t3_run_tests.sh -s composerValidate -p ${{ env.MAIN_PHP_VERSION }}
- run: composer validate

"composer-normalize":
name: "Composer normalize"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: "${{ env.MAIN_PHP_VERSION }}"
- run: |
bash .Build/bin/t3_run_tests.sh -s composerNormalize -n -p ${{ env.MAIN_PHP_VERSION }}
- run: composer normalize --dry-run --diff

"check-codestyle-codesniffer":
name: "PHP_CodeSniffer check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: "${{ env.MAIN_PHP_VERSION }}"
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ env.MAIN_PHP_VERSION }}"
- run: |
bash .Build/bin/t3_check_codestyle.sh PerCodeStyleT3Ext
bash bin/t3_check_codestyle.sh PerCodeStyleT3Ext

"check-codestyle-php-cs-fixer":
name: "PHP CS Fixer check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: "${{ env.MAIN_PHP_VERSION }}"
- run: |
bash .Build/bin/t3_run_tests.sh -s cgl -n -p ${{ env.MAIN_PHP_VERSION }}
bash bin/t3_run_tests.sh -s cgl -n -p ${{ env.MAIN_PHP_VERSION }}

"php-unit-tests":
name: "PHP Unit tests"
strategy:
matrix:
php_version: ["8.1", "8.3"]
php_version: ["8.2", "8.3"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: ${{ matrix.php_version }}
- run: |
bash .Build/bin/t3_run_tests.sh -s unit -p ${{ matrix.php_version }}
bash bin/t3_run_tests.sh -s unit -p ${{ matrix.php_version }}

"php-functional-tests-sqlite-main":
"php-functional-tests-sqlite":
name: "Functional tests on SQLite"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: "${{ env.MAIN_PHP_VERSION }}"
- run: |
bash .Build/bin/t3_run_tests.sh -s functional -d sqlite -p ${{ env.MAIN_PHP_VERSION }}
bash bin/t3_run_tests.sh -s functional -d sqlite -p ${{ env.MAIN_PHP_VERSION }}

"php-functional-tests-mariadb-main":
name: "Functional tests on MariaDB"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: ${{ env.MAIN_PHP_VERSION }}
- run: |
bash .Build/bin/t3_run_tests.sh -s functional -d mariadb -p ${{ env.MAIN_PHP_VERSION }}
bash bin/t3_run_tests.sh -s functional -d mariadb -p ${{ env.MAIN_PHP_VERSION }}

"php-acceptance-tests-mariadb":
name: "Acceptance tests on MariaDB"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: ${{ env.MAIN_PHP_VERSION }}
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ env.MAIN_PHP_VERSION }}"
extensions: intl zip
- run: |
bash .Build/bin/t3_run_tests.sh -s acceptance -d mariadb -t Backend -p ${{ env.MAIN_PHP_VERSION }}
rm -f .Build/Web/typo3/sysext/* .Build/Web/typo3conf/ext/*
composer run post-autoload-dump
bash bin/t3_run_tests.sh -s acceptance -d mariadb -p ${{ env.MAIN_PHP_VERSION }} -b docker

"php-lint":
name: "PHP linting"
strategy:
matrix:
php_version: ["8.1", "8.3"]
php_version: ["8.2", "8.3"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: ${{ matrix.php_version }}
- run: |
bash .Build/bin/t3_run_tests.sh -s lintPhp -p ${{ matrix.php_version }}
bash bin/t3_run_tests.sh -s lintPhp -p ${{ matrix.php_version }}

"phpstan":
name: "PHPStan"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: "${{ env.MAIN_PHP_VERSION }}"
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ env.MAIN_PHP_VERSION }}"
extensions: intl zip
- run: |
php -dxdebug.mode=off bin/codecept build -c Tests/codeception.yml
php -dxdebug.mode=off bin/phpstan analyse -c Build/phpstan/phpstan.ci.neon --no-progress --no-interaction --memory-limit 4G --debug

"coverage-phpunit":
name: "Test coverage by Unit Tests"
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: ${{ env.MAIN_PHP_VERSION }}
- run: |
bash .Build/bin/t3_run_tests.sh -s unit -p ${{ env.MAIN_PHP_VERSION }} -x -z coverage -e "--coverage-clover Logs/clover-unit.xml --coverage-filter ../Classes"
bash bin/t3_run_tests.sh -s unit -p ${{ env.MAIN_PHP_VERSION }} -X coverage -- --coverage-clover Logs/clover-unit.xml --coverage-filter ../Classes
- uses: actions/upload-artifact@v3
with:
name: coverage-phpunit
path: .Build/Logs/clover-unit.xml
path: Logs/clover-unit.xml
retention-days: 1

"coverage-functional":
name: "Test coverage by Functional Tests"
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: ${{ env.MAIN_PHP_VERSION }}
- run: |
bash .Build/bin/t3_run_tests.sh -s functional -d mariadb -p ${{ env.MAIN_PHP_VERSION }} -x -z coverage -e "--coverage-clover Logs/clover-functional.xml --coverage-filter ../Classes"
bash bin/t3_run_tests.sh -s functional -d mariadb -p ${{ env.MAIN_PHP_VERSION }} -X coverage -- --coverage-clover Logs/clover-functional.xml --coverage-filter ../Classes
- uses: actions/upload-artifact@v3
with:
name: coverage-functional
path: .Build/Logs/clover-functional.xml
path: Logs/clover-functional.xml
retention-days: 1

"coverage-upload":
Expand All @@ -163,7 +189,7 @@ jobs:
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: coverage-phpunit
Expand All @@ -186,11 +212,11 @@ jobs:
name: "Scan for deprecated and breaking code using typo3scan"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/workflows/composer
with:
php_version: "${{ env.MAIN_PHP_VERSION }}"
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ env.MAIN_PHP_VERSION }}"
- run: php .Build/bin/typo3scan scan --target 12 .
- run: php bin/typo3scan scan .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
/.cache
/.php-cs-fixer.cache
/.phpunit.result.cache
/bin
/composer.lock
/var
1 change: 1 addition & 0 deletions Build/cleanup_for_ter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ rm -Rf Build
rm -Rf Tests
rm -Rf typo3temp
rm -f .codeclimate.yml
rm -f .crowdin.yml
rm -f .editorconfig
rm -f .gitignore
rm ready_for_release.txt
12 changes: 12 additions & 0 deletions Build/phpstan/phpstan.ci.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
includes:
- phpstan.neon

parameters:
# CI needs to calculate phpstan a-new each time anyways. No point in caching this.
# We write this to /tmp within container which is not cached by CI.
tmpDir: /tmp

parallel:
# @todo Process timeout raised as a intermediate solution. This should be further investigated if we can mitigate
# the occurring subprocess timeout issue through other configurations and minimize the execution time again.
processTimeout: 900.0
2 changes: 2 additions & 0 deletions Build/phpstan/phpstan.local.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
includes:
- phpstan.neon
17 changes: 17 additions & 0 deletions Build/phpstan/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
includes:
- ../../.Build/vendor/bnf/phpstan-psr-container/extension.neon
- ../../.Build/vendor/friendsoftypo3/phpstan-typo3/extension.neon
- ../../.Build/vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
# Use local .cache dir instead of /tmp
tmpDir: ../../.cache/phpstan

level: 5

paths:
- ../../Classes
- ../../Tests

excludePaths:
- ../../Tests/Acceptance/Support
9 changes: 4 additions & 5 deletions Classes/Controller/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use RuntimeException;

/**
* Controller for rendering media.
Expand Down Expand Up @@ -54,6 +53,7 @@ public function renderMediaAction(): ResponseInterface
$contentObject = $this->getCurrentContentObject();

try {
/** @extensionScannerIgnoreLine */
$uid = $contentObject->data['_LOCALIZED_UID'] ?? $contentObject->data['uid'];
$media = $this->mediaRepository->findOneByContentElementUid($uid);
} catch (MediaException $mediaException) {
Expand All @@ -68,6 +68,7 @@ public function renderMediaForRelatedTableAction(): ResponseInterface
$contentObject = $this->getCurrentContentObject();

try {
/** @extensionScannerIgnoreLine */
$media = $this->mediaRepository->findOneByParentRecord($contentObject->data);
} catch (MediaException $mediaException) {
return $this->htmlResponse($this->translate('exception.' . $mediaException->getCode()));
Expand Down Expand Up @@ -98,15 +99,13 @@ private function renderMedia(Media $media): ResponseInterface
$contentObject = $this->getCurrentContentObject();
$contentObject->lastChanged($media->getTstamp());

if ($mediaType->equals(MediaType::VIDEO)) {
if ($mediaType === MediaType::VIDEO) {
return (new ForwardResponse('video'))->withArguments(['video' => $media->getUid()]);
}

if ($mediaType->equals(MediaType::AUDIO)) {
if ($mediaType === MediaType::AUDIO) {
return (new ForwardResponse('audio'))->withArguments(['audio' => $media->getUid()]);
}

throw new RuntimeException('An invalid media type is used.'); // @codeCoverageIgnore
}

/**
Expand Down
8 changes: 3 additions & 5 deletions Classes/Domain/Model/Enumeration/MediaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,24 @@
* The TYPO3 project - inspiring people to share! *
* */

use TYPO3\CMS\Core\Type\Enumeration;

/**
* Enumeration of allowed media types.
*
* @codeCoverageIgnore No code to test.
*/
class MediaType extends Enumeration
enum MediaType: string
{
/**
* Media type "audio" for MP3 / OGG files.
*
* @const
*/
public const AUDIO = 'audio';
case AUDIO = 'audio';

/**
* Media type "video" for MP4 / OGV files.
*
* @const
*/
public const VIDEO = 'video';
case VIDEO = 'video';
}
10 changes: 9 additions & 1 deletion Classes/Domain/Repository/MediaRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Sto\Html5mediakit\Domain\Model\Media;
use Sto\Html5mediakit\Exception\MediaMissingException;
use TYPO3\CMS\Core\Context\LanguageAspect;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
use InvalidArgumentException;
Expand All @@ -36,7 +37,14 @@ public function findOneByContentElementUid(int $contentElementUid): Media

// We do not want to do any language overlay in our query because the content element UID
// is already the UID of the translated content element.
$query->getQuerySettings()->setLanguageOverlayMode(false);
$languageAspect = $query->getQuerySettings()->getLanguageAspect();
$languageAspect = new LanguageAspect(
$languageAspect->getId(),
$languageAspect->getContentId(),
LanguageAspect::OVERLAYS_OFF,
$languageAspect->getFallbackChain(),
);
$query->getQuerySettings()->setLanguageAspect($languageAspect);

$query->matching($query->equals('contentElement', $contentElementUid));

Expand Down
Loading