php / php/php-src

Consistent support for NTFS streams

Ouverte
#9,230 0 commentaires 3 réactions 1 personne assignée Voir sur GitHub

@cmb69 y travaille déjà.

Depuis le 2/8/2022.

  • #9231 par @cmb69 — ouverte
Category: Streams Feature OS: Windows Status: Needs Triage
Langage dominant
C
Étoiles
40.4k
Forks
8.2k
Merge moyen
2 j 13 h
PR mergées (30 j)
96

Description

Description

The following code:

<?php
$filename = __DIR__ . "/ntfs.txt:foo";
var_dump(file_put_contents($filename, "bar"));
var_dump(file_get_contents($filename));
var_dump(file_exists($filename));
var_dump(realpath($filename));
var_dump(@stat($filename) !== false);
var_dump(basename($filename));
var_dump(file_exists(basename($filename)));

Resulted in this output for NTS builds:

int(3)
string(3) "bar"
bool(true)
bool(false)
bool(true)
string(12) "ntfs.txt:foo"
bool(false)

Resulted in this output for ZTS builds:

int(3)
string(3) "bar"
bool(false)
bool(false)
bool(false)
string(12) "ntfs.txt:foo"
bool(false)

As shown, the support for NTFS streams is totally inconsistent. Reading and writing such streams is supported, but file_exists() and stat() behave differently for NTS and ZTS builds (and even differently for NTS streams depending on whether an absolute or relative path is given). realpath() always fails.

Furthermore, pathinfo() and friends report the stream name as part of the filename, usually even as part of the file extension.

This (dangerous) inconsistency should be resolved one way or another. It might be best to completely remove support for NTFS streams for plain files, mostly to be consistent with other systems, and to avoid confusion for userland developers. A simple solution would be to "reject" such filenames, i.e. report permission denied when trying to access them. If we do this, pathinfo() and friends can likely stay as is.

If support for NTFS streams is desireable, we could introduce a new stream wrapper (say ntfs://) which would make NTFS stream access explicit.

PHP Version

all supported versions

Operating System

Windows

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.