Skip to content

[BUG] PlantumlRenderer triggers E_NOTICE when temp subdirectory doesn't exist #1

@CybotTM

Description

@CybotTM

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

  1. Configure guides to use the local PlantUML binary renderer (renderer="plantuml")
  2. Ensure the /tmp/phpdocumentor directory does not exist
  3. Render documentation containing a .. uml:: directive
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions