Skip to content

Commit

Permalink
Dev 9.19 Branch Merged To Main (#352)
Browse files Browse the repository at this point in the history
* Update to the CI.  Longterm solution should be to store build images. (#193)

* version bump to 9.19

* fix agent readme (#254)

* fix broken dev-integration-tests

* update documentation of failing tests

* add safegaurd check for getting a zval resource id

* add function to get zval object id

* change unnecessary use of macros to functions

* for PHP >= 8, fix to use zv object for curl handle instead of zv resource when getting the handle ID to access the metadata hashmap

* PR comments and PHP 5 compilation fix

* PHP 8.1: Agent changes to support PHP 8.1 (#319)

* Added .dep files to gitignore.

* Allow agent to compile against PHP 8.1 RC2

Add code for request storage handler for existing interned strings.

Fix error callback prototype for PHP >= 8.1.

Fix for PHP >= 8.1 to match MySQL PDO changes to zend_string.

Provide convert_to_explicit_type() macro for PHP >= 8.1 builds.

* Added location to search for future Zend Api Module numbers for ease of reference.

* Add PHP 8.1 to the current GHA PR workflow (#326)

* Added .dep files to gitignore.

* Allow agent to compile against PHP 8.1 RC2

Add code for request storage handler for existing interned strings.

Fix error callback prototype for PHP >= 8.1.

Fix for PHP >= 8.1 to match MySQL PDO changes to zend_string.

Provide convert_to_explicit_type() macro for PHP >= 8.1 builds.

* These cases only apply to PHP 8.0.

* Added location to search for future Zend Api Module numbers for ease of reference.

* Removed ifdefs from within function signatures for readability.

* Clang format issue in the #if statements.

* Adding PHP 8.1 to the workflow.

Co-authored-by: Michael Fulbright <mfulbright@newrelic.com>

* update pgsql instrumenting to 8.1 by using objects instead of resources

* fix pgsql tests for php 8.1

* change tests to define return type when extending for php 8.1

* skip guzzle5 tests for php 8.1+

* change null's to zero'ed types to avoid implicit conversions

* fix pdo test for php 8.1

* adjust error message test for PHP 8.1

* fix msqli class extending test for 8.1

* add guzzle5 skipif to reduce code dup

* add colored output; change ok/not ok to pass/fail

* allow XFAIL description to be missing

* final output 'expected fail' instead of 'xfail'

* replace hard tabs with soft tabs

* Add Symfony 5 support

* CR fix, add named Symfony command transactions

* remove macOS from support development list

* Modified makefiles and docs to support PHP 8.1.

* Typo :)

* Accidental space vs tab.

* test changes required to pass on a modern freebsd system

* forgot to add regex signaler

* Fix LASP test cases affected by PHP 8.1 PDO changes (#333)

* Update URL of New Relic for PHP Docs website used in error messages (#334)

fix(agent,axiom,agent/scripts): Update docs website URL

* Updates to support building PHP 8.1 and installer script (#331)

* Adds PHP 8.1 agent build and install changes

* Remove 5.3 and 5.4 from cases checked

* Remove 5.3 and 5.4 from integration and LASP test runs

* Initialize variable as function can be called multiple times

* Disable 32bit builds for PHP 8.x in GitHub workflow (#336)

* Disable workflow builds of 32bit for PHP 8.x

* Fix TAB to spaces

* Exclude 8.0-zts and 8.1-zts as well for 32 bit builds

* Parametization of release.mk (#337)

* Modified the makefile to accept specific versions to build.
If no versions are supplied, it defaults to all the PHP versions we currently support.
It automatically removes PHP versions that are not supported on the architecture.

This change was made:
* to give more flexibility as PHP versions become deprecated/EOLed on different architectures.
* to  simplifies the release.mk file
* to allow the different versions of PHP to be built depending on build node (e.g. FreeBSD10 vs FreeBSD 13).

Co-authored-by: Amber Sistla <asistla@newrelic.com>
Co-authored-by: Evgeniy <revil-on@mail.ru>
Co-authored-by: Zach Neumann <zneumann@newrelic.com>
Co-authored-by: Piotr Antosik <mail@piotrantosik.com>
Co-authored-by: Michal Nowacki <mnowacki@newrelic.com>
  • Loading branch information
6 people committed Mar 1, 2022
1 parent 8bc3f05 commit 8536ad5
Show file tree
Hide file tree
Showing 97 changed files with 2,400 additions and 349 deletions.
1 change: 0 additions & 1 deletion .github/docker/linux/x64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ RUN apt-get update && apt-get install -y \
strace \
python-dev \
python-setuptools \
python-yaml \
sqlite3 \
libsqlite3-dev \
openssl \
Expand Down
1 change: 0 additions & 1 deletion .github/docker/linux/x86/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ RUN apt-get update && apt-get install -y \
strace \
python-dev \
python-setuptools \
python-yaml \
python3-argon2 \
sqlite3 \
libsqlite3-dev \
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/agent-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ jobs:
strategy:
matrix:
os: [linux]
php_ver: ['7.0', '7.1-zts', '7.2', '7.3', '7.4', '8.0', '8.0-zts']
php_ver: ['7.0', '7.1-zts', '7.2', '7.3', '7.4', '8.0', '8.0-zts', '8.1', '8.1-zts']
arch: ['x64', 'x86']
exclude:
# Excludes PHP 5.x, 7.x on linux 32-bit
# Excludes PHP 8.x as only 64bit is supported for these versions
- os: linux
php_ver: '7.0'
arch: 'x86'
Expand All @@ -57,6 +58,18 @@ jobs:
- os: linux
php_ver: '7.4'
arch: 'x86'
- os: linux
php_ver: '8.0'
arch: 'x86'
- os: linux
php_ver: '8.0-zts'
arch: 'x86'
- os: linux
php_ver: '8.1'
arch: 'x86'
- os: linux
php_ver: '8.1-zts'
arch: 'x86'
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Build artifacts
agent/configure.ac
agent/newrelic.map
agent/*.dep
axiom/tests
bin/
pkg/
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ include make/version.mk
# Configure an isolated workspace for the Go daemon.
export GOPATH=$(CURDIR)
export GO15VENDOREXPERIMENT=1
# Needed for Go > 1.11 to avoid building with modules by default
export GO111MODULE=auto

# GOBIN affects the behavior of go install, ensure it is unset.
unexport GOBIN
Expand Down Expand Up @@ -314,7 +316,7 @@ src/newrelic/infinite_tracing/com_newrelic_trace_v1/v1.pb.go: protocol/infinite_

.PHONY: integration
integration: Makefile daemon lasp-test-all
for PHP in $${PHPS:-8.0 7.4 7.3 7.2 7.1 7.0 5.6 5.5 5.4 5.3}; do \
for PHP in $${PHPS:-8.1 8.0 7.4 7.3 7.2 7.1 7.0 5.6 5.5}; do \
echo; echo "# PHP=$${PHP}"; \
env NRLAMP_PHP=$${PHP} bin/integration_runner $(INTEGRATION_ARGS) || exit 1; \
echo "# PHP=$${PHP}"; \
Expand Down Expand Up @@ -379,7 +381,7 @@ lasp-test: daemon
if [ ! $(SUITE_LASP) ]; then echo "USAGE: make lasp-test SUITE_LASP=suite-most-secure"; exit 1; fi
if [ "$(LICENSE_lasp_$(subst -,_,$(SUITE_LASP)))" = "" ] ; then echo "Missing license for $(SUITE_LASP)"; exit 1; fi
if [ ! -d "tests/lasp/$(SUITE_LASP)" ]; then echo "No such suite in tests/lasp folder"; exit 1; fi
for PHP in $${PHPS:-8.0 7.4 7.3 7.2 7.1 7.0 5.6 5.5 5.4 5.3}; do \
for PHP in $${PHPS:-8.1 8.0 7.4 7.3 7.2 7.1 7.0 5.6 5.5}; do \
echo; echo "# PHP=$${PHP}"; \
NRLAMP_PHP=$${PHP} bin/integration_runner $(INTEGRATION_ARGS) -loglevel debug \
-license $(LICENSE_lasp_$(subst -,_,$(SUITE_LASP))) \
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.18.1
9.19.0
2 changes: 1 addition & 1 deletion agent/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ New Relic PHP Agent

For installation instructions, INI file settings,
and API descriptions please see the online FAQ at:
http://newrelic.com/docs/php/new-relic-for-php
https://docs.newrelic.com/docs/agents/php-agent/getting-started/introduction-new-relic-php/

For license and copyright, see LICENSE.

Expand Down
71 changes: 68 additions & 3 deletions agent/fw_symfony4.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ NR_PHP_WRAPPER(nr_symfony4_exception) {
goto end;
}

/* Get the exception from the event. */
exception = nr_php_call(event, "getException");
/*
* Get the exception from the event.
* Firstly, we check if ExceptionEvent is available - if yes, that means we are using Symfony 5
*/
exception = nr_php_call(event, "getThrowable");
if (!nr_php_is_zval_valid_object(exception)) {
exception = nr_php_call(event, "getException");
}

if (!nr_php_is_zval_valid_object(exception)) {
nrl_verbosedebug(NRL_TXN,
"Symfony 4: getException() returned a non-object");
Expand All @@ -59,6 +66,48 @@ NR_PHP_WRAPPER(nr_symfony4_exception) {
}
NR_PHP_WRAPPER_END

NR_PHP_WRAPPER(nr_symfony4_console_application_run) {
zval* command = NULL;
zval* input = NULL;

(void)wraprec;

/* Verify that we are using symfony 4, otherwise bail. */
NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_SYMFONY4);

/*
* The first parameter to this method should be an instance of an
* InputInterface, which defines a method called getFirstArgument which will
* return the command name, or an empty string if no command name was given.
* We can then use that to name the transaction.
*/
input = nr_php_arg_get(1, NR_EXECUTE_ORIG_ARGS TSRMLS_CC);
if (!nr_php_object_instanceof_class(
input,
"Symfony\\Component\\Console\\Input\\InputInterface" TSRMLS_CC)) {
goto leave;
}

command = nr_php_call(input, "getFirstArgument");
if (nr_php_is_zval_non_empty_string(command)) {
nr_txn_set_path("Symfony4", NRPRG(txn), Z_STRVAL_P(command), NR_PATH_TYPE_ACTION,
NR_OK_TO_OVERWRITE);
} else {
/*
* Not having any arguments will result in the same behaviour as
* "bin/console list", so we'll name the transaction accordingly.
*/
nr_txn_set_path("Symfony4", NRPRG(txn), "list", NR_PATH_TYPE_ACTION,
NR_OK_TO_OVERWRITE);
}

leave:
NR_PHP_WRAPPER_CALL;
nr_php_arg_release(&input);
nr_php_zval_free(&command);
}
NR_PHP_WRAPPER_END

NR_PHP_WRAPPER(nr_symfony4_name_the_wt) {
zval* event = NULL;
zval* request = NULL;
Expand All @@ -72,7 +121,7 @@ NR_PHP_WRAPPER(nr_symfony4_name_the_wt) {
/*
* A high level overview of the logic:
*
* RouterListener::onKernelRequest() receives a GetResponseEvent parameter,
* RouterListener::onKernelRequest() receives a GetResponseEvent (RequestEvent in Symfony 5) parameter,
* which includes the request object accessible via the getRequest() method.
* We want to get the request, then access its attributes: the request
* matcher will create a number of internal attributes prefixed by
Expand Down Expand Up @@ -185,4 +234,20 @@ void nr_symfony4_enable(TSRMLS_D) {
NR_PSTR("Symfony\\Component\\HttpKernel\\"
"EventListener\\ExceptionListener::onKernelException"),
nr_symfony4_exception TSRMLS_CC);

/*
* In Symfony 5 listener that catch errors was changed to ErrorListener,
* we try to hook into it
*/
nr_php_wrap_user_function(
NR_PSTR("Symfony\\Component\\HttpKernel\\"
"EventListener\\ErrorListener::onKernelException"),
nr_symfony4_exception TSRMLS_CC);

/*
* Listen for Symfony commands so we can name those appropriately.
*/
nr_php_wrap_user_function(
NR_PSTR("Symfony\\Component\\Console\\Command\\Command::run"),
nr_symfony4_console_application_run TSRMLS_CC);
}
45 changes: 23 additions & 22 deletions agent/newrelic-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,17 @@ if [ -z "${ispkg}" ]; then
check_file "${ilibdir}/scripts/newrelic-daemon.logrotate"
fi
check_file "${ilibdir}/scripts/newrelic.ini.template"
for pmv in "20090626" "20100525" "20121212" "20131226" "20151012" "20160303" "20170718" "20180731" "20190902" "20200930"; do
for pmv in "20121212" "20131226" "20151012" "20160303" "20170718" \
"20180731" "20190902" "20200930" "20210902"; do
# If on a 32-bit system, don't look for a PHP 8.0 build.
if [ "${arch}" = "x64" -o "${pmv}" != "20200930" ]; then
check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}.so"
check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}-zts.so"
if [ "${arch}" = "x64" ]; then
if [ "${pmv}" -lt "20200930" ]; then
check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}.so"
check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}-zts.so"
fi
fi
if [ -z "${ispkg}" ] && [ "${arch}" = "x64" ] && [ "${pmv}" != "20200930" ]; then

if [ -z "${ispkg}" ] && [ "${arch}" = "x64" ] && [ "${pmv}" -lt "20200930" ]; then
# Only check for x86 agent files on supported platforms.
case "$ostype" in
alpine|darwin|freebsd) ;;
Expand Down Expand Up @@ -507,8 +511,6 @@ add_to_path /usr/local/php
add_to_path /usr/local/php/bin
add_to_path /usr/local/zend/bin

add_to_path /usr/local/php-5.3/bin
add_to_path /usr/local/php-5.4/bin
add_to_path /usr/local/php-5.5/bin
add_to_path /usr/local/php-5.6/bin
add_to_path /usr/local/php-7.0/bin
Expand All @@ -517,12 +519,11 @@ add_to_path /usr/local/php-7.2/bin
add_to_path /usr/local/php-7.3/bin
add_to_path /usr/local/php-7.4/bin
add_to_path /usr/local/php-8.0/bin
add_to_path /usr/local/php-8.1/bin

add_to_path /opt/local/bin
add_to_path /usr/php/bin

add_to_path /usr/php-5.3/bin
add_to_path /usr/php-5.4/bin
add_to_path /usr/php-5.5/bin
add_to_path /usr/php-5.6/bin
add_to_path /usr/php-7.0/bin
Expand All @@ -531,9 +532,8 @@ add_to_path /usr/php-7.2/bin
add_to_path /usr/php-7.3/bin
add_to_path /usr/php-7.4/bin
add_to_path /usr/php-8.0/bin
add_to_path /usr/php-8.1/bin

add_to_path /usr/php/5.3/bin
add_to_path /usr/php/5.4/bin
add_to_path /usr/php/5.5/bin
add_to_path /usr/php/5.6/bin
add_to_path /usr/php/7.0/bin
Expand All @@ -542,12 +542,11 @@ add_to_path /usr/php/7.2/bin
add_to_path /usr/php/7.3/bin
add_to_path /usr/php/7.4/bin
add_to_path /usr/php/8.0/bin
add_to_path /usr/php/8.1/bin

add_to_path /opt/php/bin
add_to_path /opt/zend/bin

add_to_path /opt/php-5.3/bin
add_to_path /opt/php-5.4/bin
add_to_path /opt/php-5.5/bin
add_to_path /opt/php-5.6/bin
add_to_path /opt/php-7.0/bin
Expand All @@ -556,6 +555,7 @@ add_to_path /opt/php-7.2/bin
add_to_path /opt/php-7.3/bin
add_to_path /opt/php-7.4/bin
add_to_path /opt/php-8.0/bin
add_to_path /opt/php-8.1/bin

if [ -n "${NR_INSTALL_PATH}" ]; then
oIFS="${IFS}"
Expand Down Expand Up @@ -905,6 +905,8 @@ set_daemon_location() {
# NR_INSTALL_ARCH and NR_INSTALL_PATH to force the architecture. If
# NR_INSTALL_ARCH is set, it will always set the value of pi_arch, no matter
# what we detect.
# pi_php8
# True if PHP version is 8.0+
#
# For installation, 4 things are important:
# the extension API version, the extension load directory, and whether or not
Expand Down Expand Up @@ -957,6 +959,7 @@ gather_info() {
havecfg=
havebin=
pi_bin=
pi_php8=

#
# Get the path to the binary.
Expand Down Expand Up @@ -1010,12 +1013,6 @@ for this copy of PHP. We apologize for the inconvenience.
fi

case "${pi_ver}" in
5.3.*)
;;

5.4.*)
;;

5.5.*)
;;

Expand All @@ -1041,6 +1038,10 @@ for this copy of PHP. We apologize for the inconvenience.
pi_php8="yes"
;;

8.1.*)
pi_php8="yes"
;;

*)
error "unsupported version '${pi_ver}' of PHP found at:
${pdir}
Expand Down Expand Up @@ -1105,7 +1106,8 @@ Ignoring this particular instance of PHP.

if [ -n "${ispkg}" -a "${arch}" = "x64" ]; then
if [ "${pi_arch}" = "x86" ]; then
for pmv in "20090626" "20100525" "20121212" "20131226" "20151012" "20160303" "20170718" "20180731" "20190902" "20200930"; do
for pmv in "20121212" "20131226" "20151012" "20160303" "20170718" "20180731" \
"20190902" "20200930" "20210902"; do
check_file "${ilibdir}/agent/x86/newrelic-${pmv}.so"
check_file "${ilibdir}/agent/x86/newrelic-${pmv}-zts.so"
done
Expand Down Expand Up @@ -1207,8 +1209,6 @@ does not exist. This particular instance of PHP will be skipped.
#
pi_modver=
case "${pi_ver}" in
5.3.*) pi_modver="20090626" ;;
5.4.*) pi_modver="20100525" ;;
5.5.*) pi_modver="20121212" ;;
5.6.*) pi_modver="20131226" ;;
7.0.*) pi_modver="20151012" ;;
Expand All @@ -1217,6 +1217,7 @@ does not exist. This particular instance of PHP will be skipped.
7.3.*) pi_modver="20180731" ;;
7.4.*) pi_modver="20190902" ;;
8.0.*) pi_modver="20200930" ;;
8.1.*) pi_modver="20210902" ;;
esac
log "${pdir}: pi_modver=${pi_modver}"

Expand Down
1 change: 1 addition & 0 deletions agent/php_api_datastore.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "php_api_datastore_private.h"
#include "php_call.h"
#include "php_hash.h"
#include "php_includes.h"
#include "util_logging.h"
#include "util_sql.h"

Expand Down
Loading

0 comments on commit 8536ad5

Please sign in to comment.