Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Unable to render manual.xml with phd

Ouverte
#268 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
65/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
php
Domaine
documentation

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
PHP
Étoiles
92
Forks
60
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

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.

Autres issues de php/phd

Toutes les issues de php/phd

Issues similaires

Plus d'issues PHP

Recevez les nouvelles issues par e-mail

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