Skip to content
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
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Exclude from release archives
/.github export-ignore
/Tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
grumphp.yml export-ignore
Makefile export-ignore
phpstan.neon export-ignore
phpstan-baseline.neon export-ignore
phpunit.xml export-ignore
rector.php export-ignore
/coverage export-ignore
fractor.php export-ignore
32 changes: 18 additions & 14 deletions .github/workflows/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '8.1', '8.2', '8.3', '8.4' ]
typo3: [ '11', '12', '13' ]
exclude:
- php: '8.1'
typo3: '13'
- php: '8.4'
typo3: '11'
php: [ '82', '83', '84', '85' ]
typo3: [ '12', '13' ]
container:
image: ghcr.io/typo3/core-testing-php${{ matrix.php }}:latest
steps:
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Install dependencies
run: apk add --no-cache nodejs gpg
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
Expand All @@ -29,8 +24,17 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ matrix.php }}-composer-
- run: composer update --with typo3/minimal="^${{ matrix.typo3 }}" --no-interaction --no-progress -W --dev
- run: ./vendor/bin/grumphp run --ansi

- run: git config --global --add safe.directory $GITHUB_WORKSPACE
- run: ./vendor/bin/grumphp run --ansi --no-interaction
- run: composer test
- name: Upload coverage reports to Codecov
if: ${{ env.CODECOV_TOKEN != '' }}
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: andersundsehr/ssi_include
ter-release:
name: TER release
runs-on: ubuntu-latest
Expand All @@ -52,7 +56,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
extensions: intl, mbstring, xml, soap, zip, curl
tools: composer

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ vendor/
var/
.phpunit.result.cache
.idea/
coverage/
3 changes: 2 additions & 1 deletion Classes/Cache/Backend/SsiIncludeCacheBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function setStoreData(bool $storeData): void
*/
public function set($entryIdentifier, $data, array $tags = [], $lifetime = null): void
{
/** @phpstan-ignore function.alreadyNarrowedType */
if (!is_string($data)) {
throw new InvalidArgumentException('Data must be a string', 1616420133);
}
Expand Down Expand Up @@ -180,6 +181,6 @@ public function flushByTags(array $tags): void
*/
public function findIdentifiersByTag($tag): array
{
return parent::findIdentifiersByTag($tag);
return array_values(parent::findIdentifiersByTag($tag));
}
}
5 changes: 3 additions & 2 deletions Classes/DataProcessing/LazyDataProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ public function __construct()
public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData): array
{
$realProcessedData = 'LazyDataProcessor $realProcessedData';
$variables = $processorConfiguration['variables'] ?? ''; // given variable names to proxy
$variables .= ',' . $cObj->stdWrapValue('as', $processorConfiguration['proxiedProcessor.'] ?? [], ''); // invert variable name to proxy
$variables = (string)($processorConfiguration['variables'] ?? ''); // @phpstan-ignore cast.string
$proxiedProcessorConfig = $processorConfiguration['proxiedProcessor.'] ?? [];
$variables .= ',' . $cObj->stdWrapValue('as', is_array($proxiedProcessorConfig) ? $proxiedProcessorConfig : [], ''); // invert variable name to proxy

foreach (GeneralUtility::trimExplode(',', $variables, true) as $variableName) {
// don't overwrite existing variables with proxies
Expand Down
9 changes: 8 additions & 1 deletion Classes/Middleware/InternalSsiRedirectMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Frontend\Cache\CacheInstruction;

class InternalSsiRedirectMiddleware implements MiddlewareInterface
{
Expand All @@ -35,8 +36,14 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if (file_exists($absolutePath)) {
$content = file_get_contents($absolutePath);
} else {
$cacheInstruction = $request->getAttribute('frontend.cache.instruction');
if (!$cacheInstruction instanceof CacheInstruction) {
$cacheInstruction = new CacheInstruction();
}

$cacheInstruction->disableCache('EXT:ssi_include: Disabled cache for SSI sub-request.');
$subRequest = $request
->withAttribute('noCache', true)
->withAttribute('frontend.cache.instruction', $cacheInstruction)
->withQueryParams([])
->withUri($request->getUri()->withPath($originalRequestUri->getPath())->withQuery($originalRequestUri->getQuery()));
$handler->handle($subRequest);
Expand Down
23 changes: 16 additions & 7 deletions Classes/Proxy/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,55 @@ private function processRealInstance(): void
}
}

public function __call($name, $arguments): mixed
/**
* @param array<mixed> $arguments
*/
public function __call(string $name, array $arguments): mixed
{
$this->processRealInstance();
/** @phpstan-ignore argument.type */
return call_user_func([$this->value, $name], $arguments);
}

public function __invoke(...$arguments): mixed
public function __invoke(mixed ...$arguments): mixed
{
$this->processRealInstance();
return call_user_func($this->value, $arguments);
}

public function __isset($name): bool
public function __isset(string $name): bool
{
$this->processRealInstance();
/** @phpstan-ignore offsetAccess.nonOffsetAccessible */
return isset($this->value[$name]);
}

public function __get($name): mixed
public function __get(string $name): mixed
{
$this->processRealInstance();
/** @phpstan-ignore offsetAccess.nonOffsetAccessible */
return $this->value[$name];
}

public function __set($name, $value): void
public function __set(string $name, mixed $value): void
{
$this->processRealInstance();
/** @phpstan-ignore offsetAccess.nonOffsetAccessible */
$this->value[$name] = $value;
}

public function __unset($name): void
public function __unset(string $name): void
{
$this->processRealInstance();
/** @phpstan-ignore offsetAccess.nonOffsetAccessible */
unset($this->value[$name]);
}

public function __toString(): string
{
$this->processRealInstance();
return $this->value . '';
// @phpstan-ignore cast.string
return (string)$this->value;
}

public function current(): mixed
Expand Down
4 changes: 2 additions & 2 deletions Classes/Utility/FilenameUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ private function getSsiIncludeDir(): string
}

$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
assert($cacheManager instanceof CacheManager);
$cache = $cacheManager->getCache('aus_ssi_include_cache');
$cacheBackend = $cache->getBackend();
assert($cacheBackend instanceof SsiIncludeCacheBackend);
Expand All @@ -46,7 +45,8 @@ public function getAbsoluteFilename(string $filename): string
*/
public function getReqUrl(string $filename): string
{
$reverseProxyPrefix = '/' . trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'] ?? '', '/') . '/';
// @phpstan-ignore offsetAccess.nonOffsetAccessible, offsetAccess.nonOffsetAccessible, cast.string
$reverseProxyPrefix = '/' . trim((string)($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'] ?? ''), '/') . '/';
$includePath = rtrim($reverseProxyPrefix, '/') . $this->getSsiIncludeDir();
return $includePath . $filename . '?ssi_include=' . $filename . '&originalRequestUri=' . urlencode((string)GeneralUtility::getIndpEnv('REQUEST_URI'));
}
Expand Down
1 change: 0 additions & 1 deletion Classes/Utility/IsCacheableUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function usePageCache(?TypoScriptFrontendController $typoScriptFrontendCo
}

$context = GeneralUtility::makeInstance(Context::class);
assert($context instanceof Context);
$backendUserContext = $context->getAspect('backend.user');
if ($backendUserContext->isLoggedIn()) {
return false;
Expand Down
6 changes: 4 additions & 2 deletions Classes/ViewHelpers/RenderIncludeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function render(): string

// Get frontend user groups for their group dependent include file
$frontendUser = $this->context->getAspect('frontend.user');
/** @phpstan-ignore instanceof.alwaysTrue, function.alreadyNarrowedType */
assert($frontendUser instanceof UserAspect);
$groupString = '';
if ($frontendUser->isLoggedIn()) {
Expand All @@ -96,8 +97,8 @@ public function render(): string
$eventDispatcher->dispatch($renderedHtmlEvent);
$html = $renderedHtmlEvent->getHtml();

$cacheTags = $this->arguments['cacheTags'];
assert(is_array($cacheTags));
/** @var list<string> $cacheTags */
$cacheTags = $this->arguments['cacheTags'] ?? [];
$cacheTags[] = 'tx_ssiinclude_' . $name;

$cacheLifeTime = $this->arguments['cacheLifeTime'];
Expand Down Expand Up @@ -150,6 +151,7 @@ protected function isBackendUser(): bool

protected function getSiteName(): string
{
/** @phpstan-ignore method.nonObject */
return $GLOBALS['TYPO3_REQUEST']->getAttribute('site')->getIdentifier();
}
}
2 changes: 2 additions & 0 deletions Configuration/RequestMiddlewares.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use AUS\SsiInclude\Middleware\InternalSsiRedirectMiddleware;

return [
Expand Down
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,17 @@ docker run --rm -it \
$(ACT_IMAGE)
endef

ci:
$(DOCKER_RUN) $(PLATFORM) $(SECRETS) $(ACT_ARGS)
# ---- Targets ----
.PHONY: all ci clean

all: ci clean

ci: ## Standard-Event "push"
$(DOCKER_RUN) $(PLATFORM) $(SECRETS) $(ACT_ARGS) 2>&1 | tee /tmp/act-output.log; \
echo ""; \
echo "=== 🏁 Summary ==="; \
grep "🏁" /tmp/act-output.log || true


clean:
docker rm -f $$(docker ps -aq --filter "name=act-") 2>/dev/null || true
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![CI](https://github.com/andersundsehr/ssi_include/actions/workflows/tasks.yml/badge.svg)](https://github.com/andersundsehr/ssi_include/actions/workflows/tasks.yml)
[![codecov](https://codecov.io/github/andersundsehr/ssi_include/branch/main/graph/badge.svg)](https://app.codecov.io/github/andersundsehr/ssi_include)

# EXT:ssi_include

This Extension will help you to update your Menu's and other Partials faster if they are rendered the Same over all your Pages.
Expand Down
Loading
Loading