PHP 7.0 deprecation fix for debug_backtrace()

Created on 6 March 2025, about 1 month ago

Problem/Motivation

PHPCompatibility has detected an error for PHP 8.1 version affecting src/Message.php file: functions inspecting arguments, like debug_backtrace(), no longer report the original value as passed to a parameter, but will instead provide the current value.

FILE: /var/www/html/docroot/sites/all/modules/contrib/hook_update_deploy_tools/src/Message.php
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LINE 45: ERROR Since PHP 7.0, functions inspecting arguments, like debug_backtrace(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter
               "$variables" was changed on line 43. (PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.Changed)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   43:  ····$variables·=·self::stringifyValues($variables);
   44:  ····//·Determine·what·instantiated·this·message's·parent.
>> 45:  ····$trace·=·debug_backtrace();
   46:  ····$called_by·=·'';
   47:  ····if·(isset($trace[2]))·{
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Execute the following command:
phpcs docroot/sites/all/modules/contrib/hook_update_deploy_tools --extensions=php,module,inc --standard=PHPCompatibility --runtime-set testVersion 8.1 --report=code --report-file=reports/codereview/checkstyle-phpcompatibility_hook_update_deploy_tools.txt -sv

Proposed resolution

While being aware that there is no support for D7 modules anymore, we will contribute a patch that fixes the error as PHPCompatibility suggests.

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

1.37

Component

Code

Created by

🇪🇸Spain beagaliana

Live updates comments and jobs are added and updated live.
  • PHP 7.0

    The issue particularly affects sites running on PHP version 7.0.0 or later.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024