Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Unable to render manual.xml with phd

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
php
領域
documentation

調査の方向性

Reproduce the failure with the provided configure.php and render.php commands, then inspect phpdotnet/phd/Package/Generic/ChunkedXHTML.php:39 and the appendData() stream paths shown in the stack trace. Determine why the stream is false during IDE-JSON rendering and verify that the complete manual.xml conversion succeeds without masking the underlying stream problem.

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

説明

Hello,

I'm trying to convert php's manual.xml toJSON for easier processing.

Unfortunately I'm unable to do so.


Script
#!/bin/bash -euf

printGitRepoHash() {
	local repo="$1"

	printf "%-10s: " "$repo"

	cd "repos/$repo"

	git rev-parse HEAD

	cd ../../
}

if [ ! -d "repos" ]; then
    mkdir repos

    git clone https://github.com/php/phd.git repos/phd
    git clone https://github.com/php/doc-base.git repos/doc-base
    git clone https://github.com/php/doc-en.git repos/en
fi

printf "%s\n" "---------------------------------"

set -x
php -v
php -m
set +x

printGitRepoHash "phd"
printGitRepoHash "doc-base"
printGitRepoHash "en"

printf "%s\n" "---------------------------------"

rm -rf phd-output/

set -x

php repos/doc-base/configure.php

php -d memory_limit=4G repos/phd/render.php  \
    --format json                            \
    --package IDE                            \
    --docbook repos/doc-base/.manual.xml     \
    --output phd-output/                     \
    --lang en

Script Output
Cloning into 'repos/phd'...
Cloning into 'repos/doc-base'...
Cloning into 'repos/en'...
Updating files:  70% (8222/11740)
Updating files:  71% (8336/11740)
Updating files:  72% (8453/11740)
Updating files:  73% (8571/11740)
Updating files:  74% (8688/11740)
Updating files:  75% (8805/11740)
Updating files:  76% (8923/11740)
Updating files:  77% (9040/11740)
Updating files:  78% (9158/11740)
Updating files:  79% (9275/11740)
Updating files:  80% (9392/11740)
Updating files:  81% (9510/11740)
Updating files:  82% (9627/11740)
Updating files:  83% (9745/11740)
Updating files:  84% (9862/11740)
Updating files:  85% (9979/11740)
Updating files:  86% (10097/11740)
Updating files:  87% (10214/11740)
Updating files:  88% (10332/11740)
Updating files:  89% (10449/11740)
Updating files:  90% (10566/11740)
Updating files:  91% (10684/11740)
Updating files:  92% (10801/11740)
Updating files:  93% (10919/11740)
Updating files:  94% (11036/11740)
Updating files:  95% (11153/11740)
Updating files:  96% (11271/11740)
Updating files:  97% (11388/11740)
Updating files:  98% (11506/11740)
Updating files:  99% (11623/11740)
Updating files: 100% (11740/11740)
Updating files: 100% (11740/11740), done.
---------------------------------
+ php -v
PHP 8.4.6 (cli) (built: Apr  8 2025 19:55:31) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.4.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.6, Copyright (c), by Zend Technologies
+ php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
random
readline
Reflection
session
shmop
SimpleXML
snmp
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

+ set +x
phd       : d927213d2e417899163ba830404805d2134e42cb
doc-base  : e94861b85f24be502f4dbd11aedf3da35b7eeb6d
en        : 6e49505a1a8974ebcf31ba9bb29741bdc74a59ef
---------------------------------
+ php repos/doc-base/configure.php
configure.php on PHP 8.4.6, libxml 2.9.13

Checking for source directory... /bug/repos/doc-base
Checking for output filename... /bug/repos/doc-base/.manual.xml
Checking whether to include CHM... no
Checking for PHP executable... /opt/homebrew/Cellar/php/8.4.6/bin/php
Checking for language to build... en
Checking whether the language is supported... yes
Checking for partial build... no
Checking whether to enable detailed XML error messages... no

doc-base: e94861b85f24be502f4dbd11aedf3da35b7eeb6d
en:       6e49505a1a8974ebcf31ba9bb29741bdc74a59ef

Running file-entities.php... done: 12425 entities.
Running text-entities.php... done: 930 entities.
Checking for if we should generate a simplified file... no
Creating monolithic temp/manual.xml...  done.
Expanding XIncludes... done: 1931 tags.
Validating temp/manual.xml (libxml)... done.

All good. Saved temp/manual.xml
All you have to do now is run 'phd -d /bug/repos/doc-base/temp/manual.xml'
If the script hangs here, you can abort with ^C.
         _ _..._ __
        \)`    (` /
         /      `\
        |  d  b   |
        =\  Y    =/--..-="````"-.
          '.=__.-'               `\
             o/                 /\ \
              |                 | \ \   / )
               \    .--""`\    <   \ '-' /
              //   |      ||    \   '---'
         jgs ((,,_/      ((,,___/

PhD history: not found, creating empty, done.
PhD sources: reading, transforming, saving, done.
PhD version: reading, transforming, saving, done.
+ php -d memory_limit=4G repos/phd/render.php --format json --package IDE --docbook repos/doc-base/.manual.xml --output phd-output/ --lang en
[20:20:30 - Heads up              ] Creating output directory..
[20:20:30 - Heads up              ] Output directory created
[20:20:30 - Indexing              ] Indexing...
[20:20:30 - Rendering Style       ] Running full build
[20:20:33 - Indexing              ] Indexing done
[20:20:33 - Rendering Style       ] Running full build
[20:20:33 - Rendering Format      ] Starting IDE-JSON rendering
PHP Fatal error:  Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, false given in /bug/repos/phd/phpdotnet/phd/Package/Generic/ChunkedXHTML.php:39
Stack trace:
#0 /bug/repos/phd/phpdotnet/phd/Package/Generic/ChunkedXHTML.php(39): fwrite(false, '')
#1 /bug/repos/phd/phpdotnet/phd/Render.php(128): phpdotnet\phd\Package_Generic_ChunkedXHTML->appendData('')
#2 /bug/repos/phd/phpdotnet/phd/Format.php(324): phpdotnet\phd\Render->execute(Object(phpdotnet\phd\Reader))
#3 /bug/repos/phd/phpdotnet/phd/Package/IDE/Base.php(129): phpdotnet\phd\Format->parse('<para xmlns="ht...')
#4 /bug/repos/phd/phpdotnet/phd/Package/IDE/Base.php(350): phpdotnet\phd\Package_IDE_Base->renderHTML()
#5 /bug/repos/phd/phpdotnet/phd/Render.php(126): phpdotnet\phd\Package_IDE_Base->format_parameter_desc(true, 'listitem', Array, Array)
#6 /bug/repos/phd/render.php(175): phpdotnet\phd\Render->execute(Object(phpdotnet\phd\Reader))
#7 {main}
  thrown in /bug/repos/phd/phpdotnet/phd/Package/Generic/ChunkedXHTML.php on line 39

Fatal error: Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, false given in /bug/repos/phd/phpdotnet/phd/Package/Generic/ChunkedXHTML.php:39
Stack trace:
#0 /bug/repos/phd/phpdotnet/phd/Package/Generic/ChunkedXHTML.php(39): fwrite(false, '')
#1 /bug/repos/phd/phpdotnet/phd/Render.php(128): phpdotnet\phd\Package_Generic_ChunkedXHTML->appendData('')
#2 /bug/repos/phd/phpdotnet/phd/Format.php(324): phpdotnet\phd\Render->execute(Object(phpdotnet\phd\Reader))
#3 /bug/repos/phd/phpdotnet/phd/Package/IDE/Base.php(129): phpdotnet\phd\Format->parse('<para xmlns="ht...')
#4 /bug/repos/phd/phpdotnet/phd/Package/IDE/Base.php(350): phpdotnet\phd\Package_IDE_Base->renderHTML()
#5 /bug/repos/phd/phpdotnet/phd/Render.php(126): phpdotnet\phd\Package_IDE_Base->format_parameter_desc(true, 'listitem', Array, Array)
#6 /bug/repos/phd/render.php(175): phpdotnet\phd\Render->execute(Object(phpdotnet\phd\Reader))
#7 {main}
  thrown in /bug/repos/phd/phpdotnet/phd/Package/Generic/ChunkedXHTML.php on line 39

Patching the file mentioned in the stack trace like this:

public function appendData($data) {
    if ($this->appendToBuffer) {
        $this->buffer .= $data;

        return;
    } elseif ($this->flags & Render::CLOSE) {
        $fp = $this->popFileStream();
-       fwrite($fp, $data);
+       if ($fp) fwrite($fp, $data);
        $this->writeChunk($this->CURRENT_CHUNK, $fp);
        fclose($fp);

        $this->flags ^= Render::CLOSE;
    } elseif ($this->flags & Render::OPEN) {
        $fp = fopen("php://temp/maxmemory", "r+");
-       fwrite($fp, $data);
+       if ($fp) fwrite($fp, $data);
        $this->pushFileStream($fp);

        $this->flags ^= Render::OPEN;
    } elseif ($data !== null) {
        $fp = $this->getFileStream();
-       fwrite(end($fp), $data);
+       if ($fp) fwrite(end($fp), $data);
    }
}

It is possible for me to successfully generate output.

However, I don't know whether this the right fix or if I'm doing something wrong.

主要言語
PHP
スター
91
フォーク
59
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

php/phd のほかの issue

php/phd の issue をすべて見る

似ている issue

PHP の issue をもっと見る

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

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