facebook / facebook/hhvm

XMLWriter::writeAttributeNS does not correctly deal with null values for the namespaceUri.

Đang mở
#4,336 0 bình luận 0 reaction 1 người được giao Được @paulbiss nhận Xem trên GitHub
php5 incompatibility
Ngôn ngữ chính
C++
Star
18.7k
Fork
3.1k
Merge trung bình
1 giờ 47 phút
Pull request đã merge (30 ngày)
2

Mô tả

### Example 1: attribute is dropped

``` php
openMemory();

$xmlWriter->startDocument();

$xmlWriter->startElementNS('s', 'root', 'http://sabre.io/ns');

$xmlWriter->writeAttributeNS('s', 'foo', null, 'bar');
$xmlWriter->endElement();

echo $xmlWriter->outputMemory(), "\n";
```

Vanilla PHP output:

``` xml

```

HHVM output:

``` xml

```
### Example 2: extra xmlns declaration with empty string

``` php
openMemory();

$xmlWriter->startDocument();

$xmlWriter->startElementNS('s', 'root', 'http://sabre.io/ns');

$xmlWriter->startElementNS('s', 'child', null);
$xmlWriter->writeAttributeNS('s', 'foo', null, 'bar');
$xmlWriter->endElement();

$xmlWriter->endElement();

echo $xmlWriter->outputMemory(), "\n";
```

Vanilla PHP output:

``` xml

```

HHVM output:

``` xml

```

Interesting to note that PHP also had the same issue up until PHP 5.2.2, according to 3v4l.
### Workaround

Instead of calling:

``` php
$xmlWriter->writeAttributeNS('s', 'foo', null, 'bar');
```

It's possible to just call:

``` php
$xmlWriter->writeAttributeNS('s:foo', 'bar');
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.