Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error on PHP 5.6 + Apache2 on Docker #2012

Closed
jmakuc opened this issue Apr 12, 2023 · 2 comments
Closed

[BUG] Error on PHP 5.6 + Apache2 on Docker #2012

jmakuc opened this issue Apr 12, 2023 · 2 comments
Labels
🐛 bug Something isn't working

Comments

@jmakuc
Copy link

jmakuc commented Apr 12, 2023

Bug description

When installing the agent on an image that was working ok, every page returns http code 500, even the simple <?php phpinfo(); file.

PHP version

PHP 5.6.40 (cli) (built: Jan 23 2019 00:10:05)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with ddtrace v1.0.0-nightly, Copyright Datadog, by Datadog

Tracer version

1.0.0-nightly

Installed extensions

[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
ddtrace
dom
ereg
exif
fileinfo
filter
ftp
gd
hash
iconv
intl
json
libxml
mbstring
mcrypt
mhash
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache
ddtrace

OS info

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"

Diagnostics and configuration

Output of phpinfo() (ddtrace >= 0.47.0)

DATADOG TRACER CONFIGURATION - {"date":"2023-04-12T01:42:34Z","os_name":"Linux 756458f412c9 5.10.76-linuxkit #1 SMP Mon Nov 8 10:21:19 UTC 2021 x86_64","os_version":"5.10.76-linuxkit","version":"1.0.0-nightly","lang":"php","lang_version":"5.6.40","env":null,"enabled":true,"service":null,"enabled_cli":false,"agent_url":"http:\/\/host.docker.internal:8126","debug":true,"analytics_enabled":false,"sample_rate":1,"sampling_rules":[],"tags":[],"service_mapping":[],"distributed_tracing_enabled":true,"priority_sampling_enabled":true,"dd_version":null,"architecture":"x86_64","sapi":"apache2handler","datadog.trace.request_init_hook":"\/opt\/datadog\/dd-library\/0.86.3\/dd-trace-sources\/bridge\/dd_wrap_autoloader.php","open_basedir_configured":false,"uri_fragment_regex":null,"uri_mapping_incoming":null,"uri_mapping_outgoing":null,"auto_flush_enabled":false,"generate_root_span":true,"http_client_split_by_domain":false,"measure_compile_time":true,"report_hostname_on_root_span":false,"traced_internal_functions":null,"auto_prepend_file_configured":false,"integrations_disabled":"default","enabled_from_env":true,"opcache.file_cache":null}

Additional info

When activating the tracer debug with DD_TRACE_DEBUG=1 the following error appeared on the error log:

specto_app | [Wed Apr 12 01:51:40.227595 2023] [:error] [pid 18] [client 172.19.0.1:57150] Error raised in request init hook: syntax error, unexpected ':', expecting ';' or '{' in /opt/datadog/dd-library/0.86.3/dd-trace-sources/bridge/_generated_integrations.PHP5.php on line 4049

When looking at that file in that line, you'll find the following syntax that is not supported in PHP5.6
private static function generateFilteredPostFields(string $postKey, $postVal, array $whitelist, bool $isPrefixed) : array

There are 3 parts in the file with that problem:
root@01cd906dd4f3:/var/www/html# grep -a ": array" /opt/datadog/dd-library/0.86.3/dd-trace-sources/bridge/_generated_integrations.PHP5.php|grep -v "array()" private static function generateFilteredPostFields(string $postKey, $postVal, array $whitelist, bool $isPrefixed) : array private static function cleanRequestBody(array $requestBody, string $allowedParams) : array public static function sanitizePostFields(array $postFields) : array

I removed all three, and voila! problem gone :)

As a workaround, I've added the replace command to the container creation.

RUN sed -i 's/: array$//g' /opt/datadog/dd-library/0.86.3/dd-trace-sources/bridge/_generated_integrations.PHP5.php

@jmakuc jmakuc added the 🐛 bug Something isn't working label Apr 12, 2023
@bwoebi
Copy link
Collaborator

bwoebi commented Apr 13, 2023

Hey @jmakuc,

thanks for the report, we've indeed made a mistake here and will fix that with the next release. 0.85.0 does not contain that bug and is nearly identical too for PHP 5.

@bwoebi
Copy link
Collaborator

bwoebi commented May 12, 2023

With 0.87.0 the parse errors should be gone as well :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants