Hello!
This script behavior differs between php version you distribute and all other interpreters (even online ones)
<?php
$elementMarkup = '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Title</title>
</head>
<body>
</body>
</html>
';
$DOMDocument = new DOMDocument();
$elementMarkup = mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8');
$DOMDocument->loadHTML($elementMarkup);
$DOMDocument->removeChild($DOMDocument->doctype);
var_dump($DOMDocument->firstChild->firstChild->firstChild);
What is expected
object(DOMElement)#2 (18) {
["tagName"]=>
string(4) "meta"
["schemaTypeInfo"]=>
NULL
["nodeName"]=>
string(4) "meta"
["nodeValue"]=>
string(0) ""
["nodeType"]=>
int(1)
["parentNode"]=>
string(22) "(object value omitted)"
["childNodes"]=>
string(22) "(object value omitted)"
["firstChild"]=>
NULL
["lastChild"]=>
NULL
["previousSibling"]=>
NULL
["nextSibling"]=>
string(22) "(object value omitted)"
["attributes"]=>
string(22) "(object value omitted)"
["ownerDocument"]=>
string(22) "(object value omitted)"
["namespaceURI"]=>
NULL
["prefix"]=>
string(0) ""
["localName"]=>
string(4) "meta"
["baseURI"]=>
NULL
["textContent"]=>
string(0) ""
}
What happens when the script executed in a container
Dockerfile
FROM php:7.1-fpm-alpine
RUN apk upgrade --update && apk --no-cache add \
bash nodejs autoconf file g++ gcc binutils isl libatomic libc-dev musl-dev make re2c libstdc++ libgcc libcurl \
curl-dev binutils-libs mpc1 mpfr3 gmp libgomp coreutils freetype-dev libjpeg-turbo-dev libltdl libmcrypt-dev \
libpng-dev openssl-dev libxml2-dev expat-dev icu-dev libxslt libxslt-dev
RUN docker-php-ext-install -j$(nproc) iconv mysqli pdo pdo_mysql curl bcmath mcrypt mbstring json xml zip opcache intl xsl \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
RUN apk --no-cache add libintl gettext-dev
RUN docker-php-ext-install -j$(nproc) gettext
RUN apk add --no-cache $PHPIZE_DEPS \
&& echo no | pecl install redis \
&& docker-php-ext-enable redis
RUN apk add --no-cache $PHPIZE_DEPS \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug
RUN apk add postfix
RUN postfix start
ADD launch.sh /launch
CMD ["/launch"]
launch.sh
#!/bin/bash -e
postfix start
php-fpm
php.ini
I tried to find a reason among libxml versions, but I can not. I hope you can make things clear.
This snippet was taken from a library October CMS depends on and the issue makes impossible to run a whole project in a container.
I also tried lower php down to 7.0 but it didn't help.
Thank you.
Hello!
This script behavior differs between php version you distribute and all other interpreters (even online ones)
What is expected
What happens when the script executed in a container
Dockerfile
launch.sh
php.ini
I tried to find a reason among libxml versions, but I can not. I hope you can make things clear.
This snippet was taken from a library October CMS depends on and the issue makes impossible to run a whole project in a container.
I also tried lower php down to 7.0 but it didn't help.
Thank you.