Skip to content

Commit

Permalink
Merge pull request #572 from newrelic/dev
Browse files Browse the repository at this point in the history
Release 10.3.0
  • Loading branch information
mfulb authored Oct 28, 2022
2 parents c85c91f + e46d0e4 commit 4571e4f
Show file tree
Hide file tree
Showing 372 changed files with 11,651 additions and 6,228 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.2.0
10.3.0
4 changes: 4 additions & 0 deletions agent/fw_drupal8.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ static void nr_drupal8_add_method_callback(const zend_class_entry* ce,
* Using nr_php_op_array_get_wraprec to check if the method has valid
* instrumentation.
*/
#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
if (NULL == nr_php_op_array_get_wraprec(&function->op_array TSRMLS_CC)) {
#else
if (NULL == nr_php_get_wraprec_by_func(function)) {
#endif
char* class_method = nr_formatf(
"%.*s::%.*s", NRSAFELEN(nr_php_class_entry_name_length(ce)),
nr_php_class_entry_name(ce), NRSAFELEN(method_len), method);
Expand Down
143 changes: 80 additions & 63 deletions agent/newrelic-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ if [ -z "${ostype}" ]; then
tus=`uname -s 2> /dev/null`
case "${tus}" in
[Dd][Aa][Rr][Ww][Ii][Nn]) ostype=unsupported_os ;;
[Ff][Rr][Ee][Ee][Bb][Ss][Dd]) ostype=freebsd ;;
[Ff][Rr][Ee][Ee][Bb][Ss][Dd]) ostype=unsupported_os ;;
[Ss][Uu][Nn][Oo][Ss]) ostype=unsupported_os ;;
[Ss][Mm][Aa][Rr][Tt][Oo][Ss]) ostype=unsupported_os ;;
esac
Expand All @@ -158,7 +158,10 @@ if [ "${ostype}" = "unsupported_os" ] ; then
Your operating system is not supported by the New Relic PHP
agent. If you have any questions or believe you reached this
message in error, please file a ticket with New Relic support.
Please visit:
https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/php-agent-compatibility-requirements/
to view compatibilty requirements for the the New Relic PHP agent.
The install will now exit.
EOF
)

Expand Down Expand Up @@ -239,12 +242,21 @@ case "${arch}" in
esac

# allow override of detected arch
[ "${NR_INSTALL_ARCH}" = "x86" -o "${NR_INSTALL_ARCH}" = "x64" -o "${NR_INSTALL_ARCH}" = "x86_64" ] && arch="${NR_INSTALL_ARCH}"
[ "${NR_INSTALL_ARCH}" = "x64" -o "${NR_INSTALL_ARCH}" = "x86_64" ] && arch="${NR_INSTALL_ARCH}"

# exit if arch is unsupported
if [ "${arch}" != "x86" -a "${arch}" != "x64" ]; then
error "An unsupported architecture "${arch}" detected."
if [ "${arch}" != "x64" ]; then
msg=$(
cat << EOF
An unsupported architecture detected.
Please visit:
https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/php-agent-compatibility-requirements/
to view compatibilty requirements for the the New Relic PHP agent.
EOF
)

error "${msg}"
if [ "${arch}" = "aarch64" ]; then
cat << EOF
Expand Down Expand Up @@ -298,13 +310,6 @@ for d in "${ilibdir}/scripts" "${ilibdir}/agent" "${xtradir}"; do
done

check_dir "${ilibdir}/agent/${arch}"
if [ -z "${ispkg}" ] && [ "${arch}" = "x64" ]; then
# Only check for x86 directory on supported platforms.
case "$ostype" in
alpine|darwin|freebsd) ;;
*) check_dir "${ilibdir}/agent/x86" ;;
esac
fi

if [ -n "${dmissing}" ]; then
echo "ERROR: the following directories could not be found:" >&2
Expand Down Expand Up @@ -332,24 +337,9 @@ fi
check_file "${ilibdir}/scripts/newrelic.ini.template"
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" ]; 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}" -lt "20200930" ]; then
# Only check for x86 agent files on supported platforms.
case "$ostype" in
alpine|darwin|freebsd) ;;
*)
check_file "${ilibdir}/agent/x86/newrelic-${pmv}.so"
check_file "${ilibdir}/agent/x86/newrelic-${pmv}-zts.so"
;;
esac
fi
check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}.so"
# remove following line when ZTS removed from releases
check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}-zts.so"
done

if [ -n "${fmissing}" ]; then
Expand Down Expand Up @@ -419,7 +409,7 @@ fi
# automated installations via tools like Puppet.
#
# NR_INSTALL_ARCH
# If not empty MUST be one of x86 or x64. This overrides the attempt to
# If not empty MUST be one of x64. This overrides the attempt to
# detect the architecture on which the installation is taking place. This
# needs to be accurate. If you are installing on a 64-bit system this MUST
# be set to x64 so that the script can correctly check for whether or not
Expand Down Expand Up @@ -462,6 +452,21 @@ echo "NRVERSION: ${nrversion}" >> $nrilog
# Gather system information and store it in the sysinfo file.
#
echo "NR_INSTALL_LOCATION: ${NR_INSTALL_LOCATION}" >> $nrsysinfo
if [ "${arch}" = "x86" ]; then
msg=$(
cat << EOF
An unsupported architecture detected.
Please visit:
https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/php-agent-compatibility-requirements/
to view compatibilty requirements for the the New Relic PHP agent.
The install will now exit.
EOF
)

error "${msg}"
exit 1
fi
echo "ARCH: ${arch}" >> $nrsysinfo
nruname=`uname -a 2>/dev/null`
echo "UNAME: $nruname" >> $nrsysinfo
Expand Down Expand Up @@ -1111,16 +1116,28 @@ Ignoring this particular instance of PHP.
pi_arch="${arch}"
fi

log "${pdir}: pi_arch=${pi_arch}"

# Check if this is a supported arch
# Should be caught on startup but add check here to be sure
if [ "${pi_arch}" != "x86" -a "${pi_arch}" != "x64" ]; then
error "An unsupported architecture "${pi_arch}" detected."
echo "The install will now exit."
if [ "${pi_arch}" != "x64" ]; then
msg=$(
cat << EOF
An unsupported architecture detected.
Please visit:
https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/php-agent-compatibility-requirements/
to view compatibilty requirements for the the New Relic PHP agent.
The install will now exit.
EOF
)

error "${msg}"
exit 1
fi

# This handles both 32-bit on 64-bit systems and 32-bit only systems
if [ "${pi_arch}" = "x86" -a "${pi_php8}" = "yes" ]; then
if [ "${pi_arch}" = "x86" ]; then
error "unsupported 32-bit version '${pi_ver}' of PHP found at:
${pdir}
Ignoring this particular instance of PHP.
Expand All @@ -1130,34 +1147,6 @@ Ignoring this particular instance of PHP.
return 1
fi

if [ -n "${ispkg}" -a "${arch}" = "x64" ]; then
if [ "${pi_arch}" = "x86" ]; then
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
if [ -n "${fmissing}" ]; then
echo "ERROR: the following files could not be found:" >&2
echo "${fmissing}" | sed -e 's/^/ /' >&1
fi

if [ -n "${dmissing}" -o -n "${fmissing}" ]; then
cat <<EOF
You appear to be running on a 64-bit system and attempting to install
the 32-bit version of the agent, which is not present. Starting with
release 3.0 of the PHP agent, the 64-bit package no longer includes
the 32-bit version of the agent, and you need to explicitly install
the 32-bit version of the newrelic-php5 package. Please contact
${bold}http://support.newrelic.com${rmso} if you need assistance.
EOF
exit 1
fi
fi
fi

log "${pdir}: pi_inidir_cli=${pi_inidir_cli}"
log "${pdir}: pi_inifile_cli=${pi_inifile_cli}"

Expand Down Expand Up @@ -1288,6 +1277,21 @@ does not exist. This particular instance of PHP will be skipped.
fi
log "${pdir}: pi_zts=${pi_zts}"

# uncomment when ZTS binaries are removed
# if [ "${pi_zts}" = "yes" ]; then
# msg=$(
# cat << EOF
#
#An unsupported PHP ZTS build has been detected. Please refer to this link:
# https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/php-agent-compatibility-requirements/
#to view compatibilty requirements for the the New Relic PHP agent.
#The install will now exit.
#EOF
#)
# error "${msg}"
# exit 1
# fi

#
# This is where we figure out where to put the ini file, if at all. We only do
# this if there is a scan directory defined. If the particular PHP installation
Expand Down Expand Up @@ -1408,6 +1412,11 @@ install_agent_here() {
istat=
if [ "${pi_zts}" = "yes" ]; then
zts="-zts"

# Force copy of zts files as it is EOL so this will
# prevent future eraseure of linked to file from
# leading to a dangling symlink
NR_INSTALL_USE_CP_NOT_LN=1
fi
srcf="${ilibdir}/agent/${pi_arch}/newrelic-${pi_modver}${zts}.so"
destf="${pi_extdir}/newrelic.so"
Expand Down Expand Up @@ -1907,6 +1916,14 @@ do_uninstall() {
IFS="${ioIFS}"
gather_info "${pdir}" || continue

# keep deprecated/eol module if requested
if [ -n "${NR_UNINSTALL_KEEP_ZTS}" ]; then
if [ -z "${NR_INSTALL_SILENT}" ]; then
echo "Keeping module in ${pdir} because NR_UNINSTALL_KEEP_ZTS set."
fi
continue
fi

if [ -z "${NR_INSTALL_SILENT}" ]; then
echo "Removing from this PHP : ${pdir}"
echo " Module directory : ${pi_extdir}"
Expand Down
19 changes: 19 additions & 0 deletions agent/php_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,23 @@ extern bool nr_php_function_is_static_method(const zend_function* func);
*/
extern zend_execute_data* nr_get_zend_execute_data(NR_EXECUTE_PROTO TSRMLS_DC);

#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */

/*
* Purpose : Return a uint32_t (zend_uint) line number value of zend_function.
*
* Params : 1. zend_function.
*
* Returns : uint32_t lineno value
*
*/
static inline uint32_t nr_php_zend_function_lineno(const zend_function* func) {
if (NULL != func) {
return func->op_array.line_start;
}
return 0;
}

#endif /* PHP 7+ */

#endif /* PHP_AGENT_HDR */
21 changes: 20 additions & 1 deletion agent/php_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,14 @@ static size_t num_libraries = sizeof(libraries) / sizeof(nr_library_table_t);
static nr_library_table_t logging_frameworks[] = {
/* Monolog - Logging for PHP */
{"Monolog", "monolog/logger.php", nr_monolog_enable},
/* Consolidation/Log - Logging for PHP */
{"Consolidation/Log", "consolidation/log/src/logger.php", NULL},
/* laminas-log - Logging for PHP */
{"laminas-log", "laminas-log/src/logger.php", NULL},
/* cakephp-log - Logging for PHP */
{"cakephp-log", "cakephp/log/log.php", NULL},
/* Analog - Logging for PHP */
{"Analog", "analog/analog.php", NULL},
};

static size_t num_logging_frameworks
Expand Down Expand Up @@ -636,7 +644,11 @@ static void nr_php_show_exec(NR_EXECUTE_PROTO TSRMLS_DC) {
NRSAFELEN(nr_php_class_entry_name_length(NR_OP_ARRAY->scope)),
nr_php_class_entry_name(NR_OP_ARRAY->scope),
NRP_PHP(function_name ? function_name : "?"), NRP_ARGSTR(argstr),
#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
nr_php_op_array_get_wraprec(NR_OP_ARRAY TSRMLS_CC) ? " *" : "",
#else
nr_php_get_wraprec_by_func(execute_data->func) ? " *" : "",
#endif
NRP_FILENAME(filename), NR_OP_ARRAY->line_start);
} else if (NR_OP_ARRAY->function_name) {
/*
Expand All @@ -653,7 +665,11 @@ static void nr_php_show_exec(NR_EXECUTE_PROTO TSRMLS_DC) {
"@ " NRP_FMT_UQ ":%d",
nr_php_show_exec_indentation(TSRMLS_C), nr_php_indentation_spaces,
NRP_PHP(function_name), NRP_ARGSTR(argstr),
#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
nr_php_op_array_get_wraprec(NR_OP_ARRAY TSRMLS_CC) ? " *" : "",
#else
nr_php_get_wraprec_by_func(execute_data->func) ? " *" : "",
#endif
NRP_FILENAME(filename), NR_OP_ARRAY->line_start);
} else if (NR_OP_ARRAY->filename) {
/*
Expand Down Expand Up @@ -1142,8 +1158,11 @@ static void nr_php_execute_enabled(NR_EXECUTE_PROTO TSRMLS_DC) {
* The function name needs to be checked before the NR_OP_ARRAY->fn_flags
* since in PHP 5.1 fn_flags is not initialized for files.
*/

#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
wraprec = nr_php_op_array_get_wraprec(NR_OP_ARRAY TSRMLS_CC);
#else
wraprec = nr_php_get_wraprec_by_func(execute_data->func);
#endif

if (NULL != wraprec) {
/*
Expand Down
2 changes: 1 addition & 1 deletion agent/php_nrini.c
Original file line number Diff line number Diff line change
Expand Up @@ -2875,7 +2875,7 @@ STD_PHP_INI_ENTRY_EX("newrelic.application_logging.enabled",
newrelic_globals,
nr_enabled_disabled_dh)
STD_PHP_INI_ENTRY_EX("newrelic.application_logging.forwarding.enabled",
"0",
"1",
NR_PHP_REQUEST,
nr_boolean_mh,
log_forwarding_enabled,
Expand Down
7 changes: 5 additions & 2 deletions agent/php_rshutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,19 @@ int nr_php_post_deactivate(void) {

nrl_verbosedebug(NRL_INIT, "post-deactivate processing started");

#ifdef PHP7
#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO
/*
* PHP 7 has a singleton trampoline op array that is used for the life of an
* executor (which, in non-ZTS mode, is the life of the process). We need to
* ensure that it goes back to having a NULL wraprec, lest we accidentally try
* to dereference a transient wraprec that is about to be destroyed.
*
* For PHP 7.4+ we are not using the op_array for wraprecs
*/
#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
EG(trampoline).op_array.reserved[NR_PHP_PROCESS_GLOBALS(zend_offset)] = NULL;
#endif /* PHP7 */

#endif
nr_php_remove_transient_user_instrumentation();

nr_php_exception_filters_destroy(&NRPRG(exception_filters));
Expand Down
Loading

0 comments on commit 4571e4f

Please sign in to comment.