Skip to content

Conversation

@CybotTM
Copy link
Contributor

@CybotTM CybotTM commented Dec 9, 2025

Summary

Fixes E_NOTICE triggered by tempnam() when rendering PlantUML diagrams.

The upstream PlantumlRenderer calls tempnam(sys_get_temp_dir() . '/phpdocumentor', 'pu_') but the /phpdocumentor subdirectory may not exist, triggering:

E_NOTICE: tempnam(): file created in the system's temporary directory

This PR adds a decorator that ensures the temp directory exists before delegating to the inner renderer.

Resolves: #1099

Changes

  • Add DecoratingPlantumlBinaryRenderer that creates temp directory before rendering
  • Register decorator in DI container to wrap PlantumlRenderer
  • Add unit tests for the decorator behavior
  • Add canary test that fails when upstream fixes the issue (reminder to remove workaround)

Upstream

Test plan

  • make test-unit ENV=local passes (83 tests)
  • make code-style ENV=local passes
  • make phpstan ENV=local passes
  • Render documentation with PlantUML diagrams - no E_NOTICE in output

When using the local PlantUML binary renderer (renderer="plantuml"),
the upstream PlantumlRenderer calls tempnam() with a subdirectory
that may not exist, triggering a PHP E_NOTICE that appears in the
rendered documentation output.

This adds a DecoratingPlantumlBinaryRenderer that ensures the temp
directory exists before delegating to the inner renderer, fixing
the issue without requiring upstream changes or global E_NOTICE
suppression.

Resolves: TYPO3-Documentation#1099
Add unit tests to verify the decorator:
- Creates temp directory when missing before rendering
- Properly delegates to the inner renderer

Also changes constructor to accept DiagramRenderer interface
instead of concrete PlantumlRenderer to enable mocking in tests.

Relates: TYPO3-Documentation#1099
Change DecoratingPlantumlBinaryRenderer constructor to accept
DiagramRenderer interface instead of concrete PlantumlRenderer.

This improves testability and follows dependency inversion principle.
The decorator only needs the interface contract, not the concrete
implementation.

Relates: TYPO3-Documentation#1099
Add a test that expects tempnam() to trigger E_NOTICE when the
directory doesn't exist. When this test FAILS, it indicates that
PHP's behavior has changed or upstream has fixed the issue, and
the DecoratingPlantumlBinaryRenderer workaround may no longer
be needed.

This helps track when we can safely remove this workaround.

Relates: TYPO3-Documentation#1099
@CybotTM CybotTM force-pushed the bugfix/plantuml-tempnam-notice branch from 38bba55 to 1d44823 Compare December 9, 2025 10:05
@garvinhicking
Copy link
Contributor

We should fix this in upstream guides and not here with a decorator. Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants