Make js module compatible with php 8.1 - Positional/named arguments

Created on 30 May 2023, over 1 year ago
Updated 31 May 2023, over 1 year ago

Problem/Motivation

This line:
if (!empty($info['access callback']) && !call_user_func_array($info['access callback'], $info['access arguments'])) {
fails and produces this error with php 8.1:

Error: Cannot use positional argument after named argument in js_callback_execute() (line 35 of /var/www/html/docroot/sites/all/modules/contrib/js/includes/callback.inc).

πŸ’¬ Support request
Status

Active

Version

2.5

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States csmdgl

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @csmdgl
  • πŸ‡ΊπŸ‡ΈUnited States csmdgl
  • πŸ‡ΊπŸ‡ΈUnited States csmdgl

    Attaching patch. The problem is due to a backward breaking change in call_user_func_array(). Specifically this change: β€œIt is a fatal error to have a numeric key in args appear after a string key, or to have a string key that does not match the name of any parameter of callback.”

    This patch only does not include the entire js data from $_REQUEST in the arguments array if the php version is >= 8.

Production build 0.71.5 2024