Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- '8.2'
- '8.3'
- '8.4'
- '8.5'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ext-dom": "*",
"ext-libxml": "*",
"brotkrueml/twig-codehighlight": "^1.0",
"league/flysystem": "^1.1.10",
"league/flysystem": "^3.29",
"phpdocumentor/dev-server": "^1.9.4",
"phpdocumentor/filesystem": "^1.9",
"phpdocumentor/guides": "^1.9",
Expand Down
401 changes: 238 additions & 163 deletions composer.lock

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions packages/typo3-docs-theme/src/Directives/IncludeDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ public function processNode(
}


/**
* @throws \League\Flysystem\FileNotFoundException
*/
public function resolveGlobInclude(BlockContext $blockContext, string $inputPath, Directive $directive): LiteralBlockNode|CollectionNode|CodeNode
{
$parserContext = $blockContext->getDocumentParserContext()->getParser()->getParserContext();
Expand Down Expand Up @@ -103,9 +100,6 @@ public function resolveGlobInclude(BlockContext $blockContext, string $inputPath
return new CollectionNode($nodes);
}

/**
* @throws \League\Flysystem\FileNotFoundException
*/
public function resolveBasicInclude(BlockContext $blockContext, string $inputPath, Directive $directive): LiteralBlockNode|CollectionNode|CodeNode
{
$parserContext = $blockContext->getDocumentParserContext()->getParser()->getParserContext();
Expand All @@ -121,9 +115,6 @@ public function resolveBasicInclude(BlockContext $blockContext, string $inputPat
return $this->getCollectionFromPath($origin, $path, $directive, $blockContext);
}

/**
* @throws \League\Flysystem\FileNotFoundException
*/
public function getCollectionFromPath(\League\Flysystem\FilesystemInterface|\phpDocumentor\FileSystem\FileSystem $origin, string $path, Directive $directive, BlockContext $blockContext): LiteralBlockNode|CollectionNode|CodeNode
{
$contents = $origin->read($path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public function processNode(
}

/**
* @throws \League\Flysystem\FileNotFoundException
* @throws FileLoadingException
*/
public function loadFileFromDocumentation(BlockContext $blockContext, string $filename): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace T3Docs\Typo3DocsTheme\EventListeners;

use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;
use phpDocumentor\Guides\Event\PostRenderProcess;
use Psr\Log\LoggerInterface;
use Symfony\Component\Finder\Finder;
Expand Down Expand Up @@ -35,20 +35,15 @@ public function __invoke(PostRenderProcess $event): void
return;
}

$source = new Filesystem(new Local($fullResourcesPath));
$source = new Filesystem(new LocalFilesystemAdapter($fullResourcesPath));

/** @var \League\Flysystem\FilesystemInterface */
$destination = $event->getCommand()->getDestination();

$finder = new Finder();
$finder->files()->in($fullResourcesPath);

foreach ($finder as $file) {
$stream = $source->readStream($file->getRelativePathname());
if ($stream === false) {
$this->logger->warning(sprintf('Cannot read stream from "%s"', $file->getRealPath()));
continue;
}

Comment on lines 46 to 53
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Flysystem v3, readStream() throws a FilesystemException on failure rather than returning false. This loop currently doesn’t catch those exceptions, so a single unreadable file (or a write failure) can abort the entire post-render step; additionally, if an exception is thrown after opening $stream, fclose() may be skipped. Consider wrapping readStream + putStream in try/catch (FilesystemException) and using a finally block to always close the stream while continuing with remaining files.

Copilot uses AI. Check for mistakes.
$destinationPath = sprintf(
'%s/%s%s',
Expand Down
4 changes: 2 additions & 2 deletions packages/typo3-docs-theme/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace T3Docs\Typo3DocsTheme\Twig;

use League\Flysystem\Exception;
use League\Flysystem\FilesystemException;
use LogicException;
use phpDocumentor\Guides\Nodes\AnchorNode;
use phpDocumentor\Guides\Nodes\DocumentTree\DocumentEntryNode;
Expand Down Expand Up @@ -617,7 +617,7 @@ private function copyAsset(
$renderContext->getLoggerInformation(),
);
}
} catch (LogicException|Exception $e) {
} catch (LogicException|FilesystemException $e) {
$this->logger->error(
sprintf('Unable to write file "%s", %s', $outputPath, $e->getMessage()),
$renderContext->getLoggerInformation(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
app.ERROR: Error while processing "typo3:site-set-settings" directive in "index": Path is outside of the defined root, path: [/../../../tests/Integration/tests/site-set/input/_includes/Sets/FluidStyledContent/settings.definitions.yaml] {"rst-file":"index.rst","currentLineNumber":1} []
app.ERROR: Error while processing "typo3:site-set-settings" directive in "index": Path traversal detected: /../../../tests/Integration/tests/site-set/input/_includes/Sets/FluidStyledContent/settings.definitions.yaml {"rst-file":"index.rst","currentLineNumber":1} []
Original file line number Diff line number Diff line change
@@ -1 +1 @@
app.ERROR: Error while processing "typo3:site-set-settings" directive in "index": Path is outside of the defined root, path: [/../../../tests/Integration/tests/site-set/input/_includes/Sets/FluidStyledContent/settings.definitions.yaml] {"rst-file":"index.rst","currentLineNumber":1} []
app.ERROR: Error while processing "typo3:site-set-settings" directive in "index": Path traversal detected: /../../../tests/Integration/tests/site-set/input/_includes/Sets/FluidStyledContent/settings.definitions.yaml {"rst-file":"index.rst","currentLineNumber":1} []