php / php/php-src

Mixing processing instructions and element nodes gives inconsistent results in SimpleXML

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

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

Bug Extension: simplexml Status: Verified
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 15時間
マージ済み PR(30日)
103

説明

Description

The following code:

<?php

$xml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<container>
    <x/><?hello world?>
</container>
XML;

$sxe = simplexml_load_string($xml);

var_dump($sxe->children());

// x and hello swapped
$xml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<container>
    <?hello world?><x/>
</container>
XML;

$sxe = simplexml_load_string($xml);

var_dump($sxe->children());

Resulted in this output:

object(SimpleXMLElement)#2 (2) {
  ["x"]=>
  object(SimpleXMLElement)#4 (0) {
  }
  ["hello"]=>
  object(SimpleXMLElement)#5 (0) {
  }
}
object(SimpleXMLElement)#1 (1) {
  ["x"]=>
  object(SimpleXMLElement)#5 (0) {
  }
}

But I expected this output instead:

object(SimpleXMLElement)#2 (2) {
  ["x"]=>
  object(SimpleXMLElement)#4 (0) {
  }
  ["hello"]=>
  object(SimpleXMLElement)#5 (0) {
  }
}
object(SimpleXMLElement)#1 (1) {
  ["hello"]=>
  object(SimpleXMLElement)#%d (0) {
  }
  ["x"]=>
  object(SimpleXMLElement)#%d (0) {
  }
}
PHP Version

PHP 8.1+

Operating System

Linux

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

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

はじめの一歩

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

調査の方向性

issue にある 2 つの PHP 再現から始め、SimpleXML の実装と children() の順序に関する既存のテストを調べます。両方の入力順序で processing-instruction と element-node の処理を比較し、その後、期待される順序を示すカバレッジを追加して、関連する SimpleXML テストを実行します。

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

評価

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

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

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