iterator_count() on an SplFileObject runs endlessly
オープン
Bug
Extension: spl
Status: Verified
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
<?php
touch("/tmp/empty");
var_dump(iterator_count(new SplFileObject("/tmp/empty", "r")));
Resulted in this output:
(None. Script runs forever)
But I expected this output instead:
int(0)
It fails on files of any size, but this is the simplest I can reproduce the problem with.
Can reproduce this all the way to PHP 5.6 which is the earliest version I tried
PHP Version
PHP 8.4.12 (cli) (built: Sep 8 2025 21:17:50) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.12, Copyright (c) Zend Technologies
with Zend OPcache v8.4.12, Copyright (c), by Zend Technologies
Operating System
Tested under Linux and macOS
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、空のファイルに対して iterator_count() と SplFileObject を使用して報告された PHP スニペットを実行し、その後、これらの API の実装と既存のテストを調査します。空のファイルに対する呼び出しが終了して int(0) を返し、空でないファイルについては正しいカウントが維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100