php / php/php-src

Improvement of php://temp to add automatically prefix for debugging

Open
#20,530 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Category: Streams Feature
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Hi,

Any php code that uses temporary files uses fopen("php://temp", "w") a lot. This function does not allow putting prefix or suffix like tempnam() . And because the first expression also deletes the file automatically at file closure, it is much more convenient.

So in the end, with a big application and lots of dependencies, there are many many temporary files in /tmp/php*. When debugging the source of these files, for example to know why there are big files, it is very difficult, and requires reading source code of the app and its dependencies, and then changing to tempnam() with a prefix, which also requires manual deleting.

Instead, is-it possible to automatically add as prefix the php file name? Example:
S3Upload.php => the fopen would generate in Linux something like /tmp/php-S3Upload.php-DOoeG

I don't think there are any negative impact, I guess?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the fopen("php://temp") entry point and compare its behavior with tempnam(), especially how files under /tmp/php* are created and removed. Define the desired prefix semantics and verify that generated names improve debugging while automatic deletion remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.