Description
The PlantumlRenderer::render() method calls tempnam() with a subdirectory that may not exist, which triggers a PHP E_NOTICE:
$pumlFileLocation = tempnam(sys_get_temp_dir() . '/phpdocumentor', 'pu_');
When /tmp/phpdocumentor (or equivalent) doesn't exist, PHP emits:
Notice: tempnam(): file created in the system's temporary directory in .../PlantumlRenderer.php on line 48
This notice can appear in rendered documentation output when error reporting includes E_NOTICE.
Steps to Reproduce
- Configure guides to use the local PlantUML binary renderer (
renderer="plantuml")
- Ensure the
/tmp/phpdocumentor directory does not exist
- Render documentation containing a
.. uml:: directive
- The notice appears in the output
Expected Behavior
No PHP notices should be emitted during normal operation.
Suggested Fix
Create the directory before calling tempnam():
$tempDir = sys_get_temp_dir() . '/phpdocumentor';
if (!is_dir($tempDir)) {
mkdir($tempDir, 0777, true);
}
$pumlFileLocation = tempnam($tempDir, 'pu_');
Alternatively, simply use sys_get_temp_dir() directly without the subdirectory, since tempnam() already creates unique filenames.
Environment
- PHP: 8.1+
- phpdocumentor/guides-graphs: 1.7.3
Related
Description
The
PlantumlRenderer::render()method callstempnam()with a subdirectory that may not exist, which triggers a PHPE_NOTICE:When
/tmp/phpdocumentor(or equivalent) doesn't exist, PHP emits:This notice can appear in rendered documentation output when error reporting includes
E_NOTICE.Steps to Reproduce
renderer="plantuml")/tmp/phpdocumentordirectory does not exist.. uml::directiveExpected Behavior
No PHP notices should be emitted during normal operation.
Suggested Fix
Create the directory before calling
tempnam():Alternatively, simply use
sys_get_temp_dir()directly without the subdirectory, sincetempnam()already creates unique filenames.Environment
Related