Skip to content

Bug: dir() used instead of chdir() in viewimage/viewthumb — working directory never restored #206

@somethingwithproof

Description

@somethingwithproof

Summary

In weathermap-cacti-plugin.php, the viewimage and viewthumb code paths call dir($orig_cwd) instead of chdir($orig_cwd) to restore the working directory.

$orig_cwd = getcwd();
chdir(__DIR__);
// ...
dir($orig_cwd);   // BUG: dir() creates a Directory object, does NOT change directory

dir() is the OOP directory handle constructor. chdir() is what was meant. Working directory is never restored after serving an image, so any subsequent operation in the same request that uses relative paths silently operates from the wrong directory.

Fix

Replace dir($orig_cwd) with chdir($orig_cwd) in both viewimage and viewthumb branches.

Priority

Hard failure. Queue for Friday.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions