Skip to content
Draft
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ permissions:
jobs:
test:
runs-on: ubuntu-latest
name: TYPO3 v13.4 tests on PHP ${{ matrix.php }}
name: TYPO3 v14 tests on PHP ${{ matrix.php }}

strategy:
fail-fast: false
matrix:
php: [8.3, 8.4]
php: [8.4, 8.5]

steps:
- name: 'Checkout code'
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:

- name: 'Add title to code coverage summary'
shell: bash
run: sed -i '1 i\## TYPO3 v13.4 tests on PHP ${{ matrix.php }}' code-coverage-summary.md
run: sed -i '1 i\## TYPO3 v14 tests on PHP ${{ matrix.php }}' code-coverage-summary.md

- name: 'Add code coverage summary as pr comment'
uses: marocchino/sticky-pull-request-comment@v2
Expand Down
2 changes: 1 addition & 1 deletion .phprc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.3
8.4
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"files": ["*.php"],
"options": {
"phpVersion": "8.3",
"phpVersion": "8.4",
"printWidth": 115,
"plugins": ["@prettier/plugin-php"]
}
Expand Down
9 changes: 4 additions & 5 deletions Classes/Command/GenerateErrorPagesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Http\ServerRequestFactory;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\LinkHandling\LinkService;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
Expand Down Expand Up @@ -92,8 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
continue;
}

$request = ServerRequestFactory::fromGlobals()
->withUri($site->getBase())
$request = (new ServerRequest($site->getBase()))
->withAttribute('site', $site)
->withAttribute('language', $language);

Expand Down Expand Up @@ -194,11 +193,11 @@ private function resolveUrl(ServerRequestInterface $request, string $typoLinkUrl
$site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId((int) $urlParams['pageuid']);
} catch (SiteNotFoundException) {
// Fall back to current request for the site
$site = $request->getAttribute('site', null);
$site = $request->getAttribute('site');
}

/** @var SiteLanguage $requestLanguage */
$requestLanguage = $request->getAttribute('language', null);
$requestLanguage = $request->getAttribute('language');
// Try to get the current request language from the site that was found above
if ($requestLanguage instanceof SiteLanguage) {
try {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Service/StaticDocumentOutputService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function getErrorDocumentFromFile(int $errorCode, ServerRequestInterfa
];
foreach ($errorDocumentFileNames as $errorDocumentFileName) {
$content = $this->getContentFromPath($errorDocumentFileName);
if ($content !== null && $content !== '' && $content !== '0') {
if (!in_array($content, [null, '', '0'], true)) {
return $content;
}
}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# TYPO3 extension nxerrorhandler

[![TYPO3 V13](https://img.shields.io/badge/TYPO3-13-orange.svg)](https://get.typo3.org/version/13)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.3-8892BF.svg)](https://php.net/)
[![TYPO3 V14](https://img.shields.io/badge/TYPO3-14-orange.svg)](https://get.typo3.org/version/14)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.4-8892BF.svg)](https://php.net/)
[![GitHub CI status](https://github.com/netlogix/nxerrorhandler/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/netlogix/nxerrorhandler/actions)

Improves error handling in TYPO3 by using statically rendered error documents for output to reduce strain on the server.

## Compatibility

The current version of this extension has been tested in TYPO3 13 on PHP 8.3, 8.4.
The current version of this extension has been tested in TYPO3 14 on PHP 8.4, 8.5.

## Usage

Expand Down
12 changes: 3 additions & 9 deletions Tests/Functional/Command/GenerateErrorPagesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Netlogix\Nxerrorhandler\Tests\Functional\Command;

use Override;
use FilesystemIterator;
use Netlogix\Nxerrorhandler\Command\GenerateErrorPagesCommand;
use Netlogix\Nxerrorhandler\Service\ConfigurationService;
Expand All @@ -16,7 +15,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

class GenerateErrorPagesCommandTest extends FunctionalTestCase
final class GenerateErrorPagesCommandTest extends FunctionalTestCase
{
protected array $pathsToLinkInTestInstance = [
'typo3conf/ext/nxerrorhandler/Tests/Functional/Fixtures/Sites' => 'typo3conf/sites',
Expand All @@ -37,28 +36,23 @@ class GenerateErrorPagesCommandTest extends FunctionalTestCase
],
];

#[Override]
protected function setUp(): void
{
parent::setUp();

$this->purgeCreatedDirectoriesAndFiles();
}

protected function purgeCreatedDirectoriesAndFiles()
protected function purgeCreatedDirectoriesAndFiles(): void
{
if (is_dir(ConfigurationService::getErrorDocumentDirectory())) {
GeneralUtility::rmdir(ConfigurationService::getErrorDocumentDirectory(), true);
}
}

#[Override]
protected function tearDown(): void
{
restore_exception_handler();

parent::tearDown();

$this->purgeCreatedDirectoriesAndFiles();
}

Expand All @@ -67,7 +61,7 @@ public function itCreatesErrorDocumentDirectory(): void
{
$this->assertDirectoryDoesNotExist(ConfigurationService::getErrorDocumentDirectory());

$subject = $this->createMock(GenerateErrorPagesCommand::class);
$subject = $this->createStub(GenerateErrorPagesCommand::class);

$reflectionObject = new ReflectionObject($subject);
$reflectionMethod = $reflectionObject->getMethod('initialize');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Netlogix\Nxerrorhandler\Tests\Functional\Service;

use Override;
use Netlogix\Nxerrorhandler\Service\StaticDocumentOutputService;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Http\ServerRequest;
Expand All @@ -13,7 +12,7 @@
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

class StaticDocumentOutputServiceTest extends FunctionalTestCase
final class StaticDocumentOutputServiceTest extends FunctionalTestCase
{
protected array $pathsToLinkInTestInstance = [
'typo3conf/ext/nxerrorhandler/Tests/Functional/Fixtures/Sites' => 'typo3conf/sites',
Expand Down Expand Up @@ -58,11 +57,9 @@ public function itTriesToFetchContentForLanguageCombinations(): void
$subject->getOutput($errorCode, $request);
}

#[Override]
protected function setUp(): void
{
parent::setUp();

$this->importCSVDataSet(__DIR__ . '/../Fixtures/pages.csv');
$this->setUpFrontendRootPage(1);
}
Expand Down
5 changes: 1 addition & 4 deletions Tests/Unit/Error/PageContentErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Netlogix\Nxerrorhandler\Tests\Unit\Error;

use Override;
use Netlogix\Nxerrorhandler\Error\PageContentErrorHandler;
use Netlogix\Nxerrorhandler\Service\StaticDocumentOutputService;
use PHPUnit\Framework\Attributes\Test;
Expand All @@ -15,7 +14,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

class PageContentErrorHandlerTest extends UnitTestCase
final class PageContentErrorHandlerTest extends UnitTestCase
{
private MockObject&PageContentErrorHandler $subject;

Expand Down Expand Up @@ -56,11 +55,9 @@ public function itReturnsStaticContentIfExists(): void
$this->assertSame($content, $resp->getBody()->getContents());
}

#[Override]
protected function setUp(): void
{
parent::setUp();

$this->subject = $this->getMockBuilder(PageContentErrorHandler::class)
->addMethods([])
->disableOriginalConstructor()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Service/ConfigurationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PHPUnit\Framework\Attributes\Test;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

class ConfigurationServiceTest extends UnitTestCase
final class ConfigurationServiceTest extends UnitTestCase
{
#[Test]
public function itCanGetErrorDocumentDirectory(): void
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Service/StaticDocumentOutputServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

class StaticDocumentOutputServiceTest extends UnitTestCase
final class StaticDocumentOutputServiceTest extends UnitTestCase
{
#[Test]
public function itAddsCurrentUrlToErrorDocument(): void
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"license": "MIT",
"type": "typo3-cms-extension",
"require": {
"php": ">=8.3",
"typo3/cms-core": "^13.4",
"typo3/cms-frontend": "^13.4"
"php": "^8.4 || ^8.5",
"typo3/cms-core": "^14.3",
"typo3/cms-frontend": "^14.3"
},
"require-dev": {
"ext-sqlite3": "*",
"ergebnis/composer-normalize": "^2.45",
"phpunit/phpcov": "^10.0",
"ssch/typo3-rector": "^3.0",
"typo3/testing-framework": "^9.0"
"ssch/typo3-rector": "^3.14",
"typo3/testing-framework": "^9.6"
},
"autoload": {
"psr-4": {
Expand Down
9 changes: 4 additions & 5 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
Expand All @@ -23,18 +23,17 @@
typeDeclarations: true,
instanceOf: true,
earlyReturn: true,
strictBooleans: true,
)
->withImportNames(removeUnusedImports: true)
->withSets([
LevelSetList::UP_TO_PHP_83,
LevelSetList::UP_TO_PHP_84,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::DEAD_CODE,
SetList::TYPE_DECLARATION,
SetList::EARLY_RETURN,
SetList::INSTANCEOF,
Typo3LevelSetList::UP_TO_TYPO3_13,
Typo3LevelSetList::UP_TO_TYPO3_14,
PHPUnitSetList::PHPUNIT_100,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
Expand All @@ -51,5 +50,5 @@
__DIR__ . '/public/*',
__DIR__ . '/.github/*',
__DIR__ . '/.Build/*',
FirstClassCallableRector::class => [__DIR__ . '/Configuration/Services.php'],
ArrayToFirstClassCallableRector::class => [__DIR__ . '/Configuration/Services.php'],
]);
Loading