php / php/php-src

Inconsistent result stream with or without a function wrapper

オープン
#19,525 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Category: Streams Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.1k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

The following code:

<?php
class Loader {
    public $context;
    private $position;
    private $data;
    public function stream_open($path, $mode, $options, &$opened_path)  {
        $this->data = '<' . "?php \n\"\";ll l\n ?" . '>';
        $this->position = 0;
        return true;
    }
    function stream_read($count) {
        $ret = substr($this->data, $this->position, $count);
        $this->position += strlen($ret);
        return $ret;
    }
    function stream_eof() {
        return $this->position >= strlen($this->data);
    }
    function stream_flush() {
        var_dump("flush!");
    }
    function stream_close() {
        @unlink(__DIR__."/bug38779.txt");
        var_dump("close!");
    }
}
stream_wrapper_register('Loader', 'Loader');
$fp = fopen ('Loader://qqq.php', 'r');
$filename = __DIR__."/bug38779.txt";
$fp1 = fopen($filename, "w");
fwrite($fp1, "<"."?php blah blah?".">");
fclose($fp1);
include $filename;

Resulted in this output:

Parse error: syntax error, unexpected identifier "blah" in /tmp/bug38779.txt on line 1
string(6) "close!"

The following code:

<?php
function foo() 
{
class Loader {
    public $context;
    private $position;
    private $data;
    public function stream_open($path, $mode, $options, &$opened_path)  {
        $this->data = '<' . "?php \n\"\";ll l\n ?" . '>';
        $this->position = 0;
        return true;
    }
    function stream_read($count) {
        $ret = substr($this->data, $this->position, $count);
        $this->position += strlen($ret);
        return $ret;
    }
    function stream_eof() {
        return $this->position >= strlen($this->data);
    }
    function stream_flush() {
        var_dump("flush!");
    }
    function stream_close() {
        @unlink(__DIR__."/bug38779.txt");
        var_dump("close!");
    }
}
stream_wrapper_register('Loader', 'Loader');
$fp = fopen ('Loader://qqq.php', 'r');
$filename = __DIR__."/bug38779.txt";
$fp1 = fopen($filename, "w");
fwrite($fp1, "<"."?php blah blah?".">");
fclose($fp1);
include $filename;
}
foo();

Resulted in this output:

Parse error: syntax error, unexpected identifier "blah" in /tmp/bug38779.txt on line 1
PHP Version
nightly
Operating System

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供されている 2 つの PHP スクリプトを nightly build 上で再現し、function wrapper の内側と外側での stream wrapper と include の動作を比較します。wrapper がいつ閉じられるかを追跡し、焦点を絞った回帰テストを追加する前に、期待される一貫した結果を特定します。この issue では、既存のテストファイルや実装のエントリーポイントは指定されていません。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
28/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。